Got gists? Post them here!

Hey guys, just thought it’d be nice to try to gather various gists that have been floating around showing small Fuse code snippets. As always we’re trying to improve the docs so if we see stuff that fits we’ll put it in there, but I think it’s also nice to have kind of an “informal repository” of snippets other people can dig through :slight_smile:

So, to start, here’s one that came from fiil on slack, showing how to play an iOS system sound using JS, UX, and Uno:

If you guys have any others, please share! :slight_smile:

If you have the desire to separate out JS files, then this might come in handy.

For this example you want a Colors.js to house all of your colors:

var red = #FF0000;

module.exports = {
    red: red

Then in your Main.js:

var Observable = require("FuseJS/Observable");

var Colors = require('Colors');

module.exports = {
    Colors: Colors

In your MainView.ux all you need to do is:

<App Theme="Basic">
    <JavaScript File=“Colors.js” ux:Global=“Colors” />
    <JavaScript File=“Main.js” />

    <Panel Background=“{}”>
        <!-- Stuff in here -->

That’s pretty neat!

Thats cool!

I guess then it is possible to create typescript files, and then compile them to es5 and import!

I’ll try it…

That’s what I did with CoffeeScript. It has a coffe -w option, where it will watch a directory and automatically compile to JS every time you save. And since Fuse picks up changes to your JS files automatically, you get instant live coding of CoffeeScript in your Fuse preview. Even works on device! :slight_smile:

This might sound a bit odd,

but i’ve been compiling the .ux files in Jade and the JS files in typescript. If you run jade in the terminal with the -E ux flag, they compile straight into .ux files.