concord-consortium/lab — pull request #57 by pjanik (2013-12-19 12:57:20+00:00)
Title: Initialization path refactoring

I think it's the right moment to merge changes into master and be prepared for possible issues and extensive testing.

Main changes that are visible for users:
- interactive reload button in the top-left corner of the interactive
- consistent convention that components do not intitialize themselves on model load
- consistent convention that components that have an action script call it *only* when they are really clicked, changed, touched etc. by the user. They do not call it during the initialisation or on model load.
- there is no more a special option in pulldown and radio called "loadModel". Now you should just use "action": "loadModel('modelID');" instead.

Things changed under the hood:
Especially interactives controller is affected and its method like ```loadInteractive``` and ```loadModel```.

Interactive load starts with the creation of all components and helper objects. Then the model is loaded, modeler object obtained and bound to various helpers that expect it (like scripting API). Previously we had pretty weird paths for loading interactive and model, plus especially weird path for model reload. Now reload is basically load of the same model.

Too get the difference you can take a look at the diagrams here:
https://groups.google.com/d/msg/lab-models/Q9Itvt5piGY/D92xd7OzomIJ
compare images with and without NEW suffix. Initialization sequence is now more similar to one described in NEW.

The thing that I haven't done completely is limiting number of events. I've tried to make events handling in interactives controller more consistent (see its ```on``` method), but still I feel we emit too many similar events (e.g. "modelLoaded" both in interactives and model controller).

Note also that we were thinking that it should take about two weeks, but I would say that time spent on that refactoring until now is like one week. We definitely shouldn't end the topic completely. It's just the first step and will be useful for further work related to parameters retainment.