This prototype demonstrates an implementation of the engine service.
When the Add Engine button is clicked, an HTML element - <engine /> - is dynamically added to the document.
When the Load Engines button is clicked, the engine service checks to see if any <engine /> elements exist in the document.
If one or more of these elements exist, the first element becomes the primary engine.
If no elements exist, the engine service creates a new primary engine without adding an element to the page.
The primary engine has a different set of responsibilities than subsequent engines, namely that of loading the external configuration data and initializing additional components.
At present, the default behavior of the primary engine is as follows.
Create task engine_loader with an action to load an xml file and a handler to import the task engine_driver.
The engine_driver task has no action and a handler to publish the engine_service_initialized message, and depends on setup_config, create_style_source, import_class_definitions, and dom_event_window_load.
The setup_config task has a script action that executes a CDATA block and loads config params into the ApplicationDriver object, and has no handler. Note that the config script manually returns the dependency.
The dom_event_window_load dependency (not an actual task) is returned when the ApplicationDriver publishes a message that the window.onload fired. Note: only ApplicationDriver bothers with listening to the window onload, onunload, and onbeforeunload events.
The import_class_definitions task has an action to execute CDATA script that loads component data from the config file, and it has no handler. Note: the component data being in the config is a proof of concept.
The create_style_source task has an action to execute CDATA script, and no handler. The action initializes a component that loads xml-based style data and subscribes to the message published by the component that the style data was loaded. The custom handler unsubscribes itself when the data is loaded, and then returns the dependency an the task.
bug: resetting the engines will not reset child tasks and transactions initiated by the original task. Only the loader_task is reset. This means resetting the engines will not allow the primary engine to load a second time.