How can I store a variable in a module such that app.coffee can reference it?
@options.myVar ?= true
will be available within the module and can be overwritten during initialization, but I can't see how to query it from app.coffee afterward.
if you look in any new framer studio project in the modules folder there is an example module called myModule with some instructions. So for just a variable it says: exports.myVar = "myVariable" ... just remember to include your module in your main code: myModule = require "myModule" ... then you can reference it as myModule.myVar = "whatever" ... hope that helps! it's all in the example module :)
exports.myVar = true
Why `@options.myVar`? Is this part of a constructor in a class? If so, you should be able to reference it with dot notation from it's parent if you do `super @options`. Ex: `myClass.myVar`
Also, post example code if you can. Context would be helpful here.
Example code here. This isn't quite like myModule.coffee, as I'm using the variable within a class which extends Layer.
Hey John Marstall, You can't get the value because you haven't set the "getters" and "setters" for that option to retrieve and re-write the value past initialization. Check out this example: http://share.framerjs.com/p5phnkyf8rfq/
I am a color-by-numbers coffeescript dude, but my lizard brain understanding is that you have to explain what to do when you ask for that option's value and what to do when you try to overwrite that option's value. Hope that helps!
Layers have a special property called "custom" where you can save whatever you want, also during construction. If you extend the Layer class you get this "custom" property for free. Else you could create your own custom data property.