Gaia/System/Refactoring Plan: Difference between revisions

Line 23: Line 23:
// (we need to expose the system instance because test atoms need to call some functions directly)
// (we need to expose the system instance because test atoms need to call some functions directly)
window.system = new System();
window.system = new System();
window.system.start();


</pre>
</pre>
Line 31: Line 32:


var System = function System() {
var System = function System() {
  /* some initial states */
  this.started = false;
};
System.prototype.start = function() {
  this.started = true;
  /* modules */
   this.appWindowFactory = new AppWindowFactory(this);
   this.appWindowFactory = new AppWindowFactory(this);
   this.appWindowManager = new AppWindowManager(this);
   this.appWindowManager = new AppWindowManager(this);
   this.screenManager = new ScreenManager(this);
   this.screenManager = new ScreenManager(this);
  /* event listeners */
};
};


.. prototype methods follows ..
.. other prototype methods follows ..


</pre>
</pre>


'''Caveat''': Please take care of instantiation timing and dependency. Please ensure the rewrite does not break anything (run tests!). If you think the parent instance need explicit control over initialization, you may create <code>init()</code> and more some code there.
'''(TBD: jsdocs)'''
 
'''Caveat''': Please take care of instantiation timing and dependency. Please ensure the rewrite does not break anything (run tests!). A pair of <code>init()</code>/<code>start()</code> and <code>uninit()</code>/<code>stop()</code> function is recommended to give the instance an explicit start and finish.


With this pattern we are able to do unit test anywhere,
With this pattern we are able to do unit test anywhere,
Confirmed users
478

edits