Have a coffeescript question; specifically regarding scope.
Leveraging Marc Krenn's awesome Firebase module to semi power-up my prototype. Coffeescript's scoping is becoming an issue when trying to push a dataset into an array. Pulling the example from Github:
firebase.get "/names", (names) -> namesArray = _.toArray(names) print name for name in namesArray
Initializing namesArray outside the method isn't enough to update its value. Any ideas on the proper way to deal with this?
Quick update: I don't think this has to do with scope. This seems to be more of a promises / callback issue w/ firebase.get either returning a promise or callback function! I'll update once again if I find a solution.
Just to wrap this thread up - best is to load your firebase data before loading the rest of your app (or before loading a specific screen). At the end it was a promises / callback issue w/ the firebase.get method. It's probably due to the fact that JS is single threaded. Anyways if anyone runs into this or needs help just ask and I can post work arounds.