Control Mapping
Lotus.Context.controllerMap.mapView({component:'SomeFunction', mediator:SpiSdk.SomeMediator });
Lotus.Context.controllerMap.unmapView({component:'SomeFunction', mediator:SpiSdk.SomeMediator });
After view components have been processed by x-tag the context iterates over the view component instances stored in the Lotus.ComponentMap.componentInstances and if the component instance constructor matches a function mapped to the controller map it creates new controller instance, stores a reference to it, and calls the controller's onRegister method passing the view component instance. Be sure the controller instance is typed into the component lifecycle similar to view components. Event dispatching seems like the obvious choice on how to do this.
Controllers
required, all controllers must extend AbstractController
Lotus.AbstractController = function(){
//add view getter (read only!)
}
Lotus.AbstractController.prototype.onRegister = function( element ){
//stub for override
}
Lotus.AbstractController.prototype.addEventListeners = function( element ){
//stub for override, attach event listeners on the view
//mediators are expected to have some knowledge of the view they are mediating, IE what events to listen for on what part of the view
}
Lotus.AbstractController.prototype.removeEventListeners = function( element ){
//stub for override
}
//called by mediator map when element is removed
Lotus.AbstractController.prototype.onRemove = function( event ){
this.destroy();
}
Lotus.AbstractController.prototype.destory = function(){
//stub for override
}