Skip to content

Instantly share code, notes, and snippets.

@arieh
Created February 27, 2013 22:03
Show Gist options
  • Save arieh/5052220 to your computer and use it in GitHub Desktop.
Save arieh/5052220 to your computer and use it in GitHub Desktop.
how do I solve this issue w/ AMD?
//what we currently have
//test1.js
widget.register('test1',{
//widget code
});
//test2.js
widget.register('test2',{
//....
})
/*
so by simply including these files, the widgets would be registered, and thus we can just do something like
widget.loadAll();
and all widgets would be loaded
*/
//AMD
//test1.js
define(['widget'], function(widget){
return widget.register('test1',{
//....
});
});
/*
since no one "requires" test1 in order to run, there is no where in the execution flow
where test1 would be included. So I would have to have a file that would look something like
*/
//widget-loader.js
define(['test1','test2','test3','foo','bar'],function(){});
/*
and add it as a dependancy
this means that everytime I create a new widget, I also have to add it here
this is a very bad pattern (list would becode too long to maintain, developers would forget to add files etc)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment