Hello everyone,
I'm trying to figure out, why is the Cookie module only accessible after it has been instantiated using new operator... I thought that if I exported the Cookie module in shim config and added the module name to the per-requisites in app.js, it would be globally accessible. But it's not.
Can you please advise on what may be wrong with my module?
cookie.js
define("Cookie",function (){
function Cookie()
{}
Cookie.prototype.add = function ()
{
doStuff();
}
Cookie.prototype.remove = function ()
{
doStuff();
}
return Cookie;
});
main.js
requirejs.config({
baseUrl: 'js/lib',
paths: {
app: '../app',
},
shim:{
Cookie: {
exports : 'Cookie'
}
}
});
app.js
define(['Cookie'],function(Cookie)
{
Cookie.add();
Cookie.remove();
}