init.js 643 B

123456789101112131415161718192021222324
  1. (function (root, overrides) {
  2. var reload = window.location.reload.bind(window.location);
  3. Glagol.events.on('changed', reload);
  4. root.events.on('changed', reload);
  5. var App = { root: root };
  6. overrides = overrides || {};
  7. ['model', 'socket', 'style'].map(install.bind(null, false));
  8. ['templates', 'events'].map(install.bind(null, true));
  9. function install (dir, name) {
  10. var defaultName = './' + name + (dir ? '' : '.js');
  11. App[name] = App.root.get(overrides[name] || defaultName);
  12. }
  13. _.tasks.model(App);
  14. if (App.socket) _.tasks.socket(App);
  15. if (App.style) _.tasks.style(App);
  16. _.tasks.view(App);
  17. return App;
  18. })