Do you know if it's possible to reference a layer created in app.coffee from a Class in a .module?
Johannes Eckert sorry to dig up old skeletons, I'm running into a similar problem, did you ever find a solution to your problem? I would really like to get my module to have the same scope as app.coffee
haha, fair enough...i am doing the same thing.. let's keep this under wraps :P
It's possible... Are you getting errors?
Should a module really know / care about things outside the module though?
Maybe this isn't best practice, but attach your layers or variables to the window object?
It's throwing the error: [framer.modules.js] ReferenceError: Can't find variable: myLayer
Instantiated your class in a function and attached the layer to the window object: http://share.framerjs.com/t9gsmfuvgv2c/
Thanks Zoltan :)
Do you think there is a cleaner way?
Maybe could replace the module with js via Utils.domLoadScriptSync and lose the function
Why don't you just pass that layer to your module so its scope knows about it?
How do you currently use your module?
There are a number of ways to do this, one of which would be to extract that variable into it's own module, and then require it in both app.coffee and your module
Or set it in window (make it a global). Then you module can just access it.
Thanks. I'll try both :)
Does your module have a class? Or is it more code with similar structure to app.coffee?
Jordan, yes. It has a class. I posted yesterday this example: http://share.framerjs.com/r1b5fx55oh0h/
Oh! I missed that.
Okay well you would call a method from that class and pass in your layer to it so it's aware of it and store it in the scope of the module.
I can take a look in about 2 hours. :)
I have to work on a macbook air currently, and at around 500 lines of code in app.coffee, saving and rendering takes between 1 and 3 seconds and is really painful. I am looking for a way to just separate my code out into single chunks that should compile quicker. For that, these "modules" should act as they were part of app.coffee. I would like not to worry about scope.
That makes sense Johannes Eckert. Completely. I've been there.