I have a module foo
which returns a singleton object. I want to perform some configuration/setup on this module on one part of my page, then use it later on. (Say perhaps the config occurs in some shared partial view).
require(['foo'], function(Foo) {
Foo.value = 'abc';
});
// Then, later on on the same page...
require(['foo'], function(Foo) {
alert ('Foo value is ' + Foo.value);
});
So even though RequireJS may execute require
s out of order based on when dependencies are loaded, can I be sure that the second call will occur only after the first has finished since they have the same dependencies?
If not, what is a better way to accomplish this?