bbuchsbaum / active_brain

1 stars 0 forks source link

Session variable falls out of scope #3

Open phillipCouto opened 9 years ago

phillipCouto commented 9 years ago

The code at activeb_master.coffeeL#26 doesn't assign the session variable to a scope that is accessible to code running at activeb_master.coffeeL#28

What may work out better is to use a Promise A+ spec library like bluebird in place of jQuery's lacking implementation. The reason for this is you can use a method like Promise.join that will allow you to assign multiple promises that need to be resolved before the handler is executed. The promise results will be arguments to the function so the code could look like this:

Promise.join($.getJSON("/subject"),$.getJSON("/session"), function(subject, session) {
...
})
.catch(function(e) {
console.log(e);
});

Sorry I am not too familiar with coffee script hence why my examples are in plain JS.

bbuchsbaum commented 9 years ago

feel free to replace my code with the Promise A+ spec library. I resorted to assigning session and subject to "window"