If I want a module that is instantiable, let say, a module that handles storing preferences in a subcookies, and i want the main cookie to be configurable, but i don't want it to be a widget... what patterns should i use with YUI?
the end code should be something:
Y.use('my-pref-manager', function(Y){
var A = Y.my-pref-manager.prefStore('A"),
B = Y.my-pref-manager.prefStore('B");
// A and B are now loaded with the contents of cookies A and B, if they exist
A.set('xy', 123 );
});
So far i either found patterns that create widgets within my-module or i have to use methods directly in my-method which will be globals and lack initializers, etc.
There is a bunch of ways of doing this. You could do it using
Y.Base.create
, like below. The code might not be production ready, or even working properly, but hopefully it answers how you can create a module without it being a Widget.The code below creates a module that extends
Y.Base
. This let us useAttributes
and other cool things. Check the doc for Y.Base.Try it out: http://jsfiddle.net/B62nu/