Reputation: 7990
I have a dojo-based module that automates loading a dojo/store/Memory for me, using a bang. It's called like so:
require( [ 'squad_builder/storeBroker!collectionStore' ],
function( collectionStore )
{
// use store...
} );
The first require() call loads the store and subsequent ones load the store from a cache.
This works well but I cannot figure out how to invalidate require's internal cache so I can make the next request load the store with fresh data.
Is there anything built into require() to do this or do I need to mess with some internal workings (and if so, where?)
Edit
In the docs it mentions:
Note: the dojo loader includes the nonstandard function require.undef, which undefines a module value.
But that method is undefined when I call it. Looking at require() in Firebug with:
for( i in require )
{
console.log( 'require', i, require[ i ] );
}
require.module has a def()
method but not an undef()
one.
Edit 2
Require.cache
only seems to contain dojo and dijit modules. Where are custom namespaced modules cached?
Upvotes: 1
Views: 1281
Reputation: 2698
According to the dojo site, the function is not automatically included in "built" dojo files. If you look at an uncompressed dojo.js you will see it there. From:http://dojotoolkit.org/reference-guide/1.9/loader/amd.html
The following table provides a list of options that are leveraged within the loader. The first column is the Option/Feature as defined within the loader, the second options is whether this is a detected feature (via has.add()) or if it is just an option and its default value. With “unbuilt” source, all the features and options are available. If the loader has been built, then some of these features may have been set as staticHasFeatures and not be configurable anymore.
Also here it says that you might be able to turn the function back on by adding a line go djconfig http://dojo-toolkit.33424.n3.nabble.com/require-undef-td3990559.html
dojoConfig = { has : { "dojo-undef-api": true } }
Upvotes: 1