Class | Facade |
In: |
src/org/puremvc/ruby/patterns/facade/facade.rb
|
Parent: | Object |
In PureMVC, the Facade class assumes these responsibilities:
controller | [RW] | |
model | [RW] | |
view | [RW] |
This Facade implementation is a Singleton, so you can not call the constructor directly, but instead call the static Singleton Factory method Facade.instance
Initialize the Controller.
Called by the initialize_facade method. Override this method in your subclass of Facade if one or both of the following are true:
If you don‘t want to initialize a different Controller, call super at the beginning of your method, then register Commands.
Initialize the Singleton Facade instance.
Called automatically by the constructor. Override in your subclass to do any subclass specific initializations. Be sure to call super.
Initialize the Model.
Called by the initialize_facade method. Override this method in your subclass of Facade if one or both of the following are true:
the Facade at construction time.
If you don‘t want to initialize a different Model, call super at the beginning of your method, then register Proxys.
Note: This method is rarely overridden; in practice you are morelikely to use a Command to create and register Proxys with the Model, since Proxys with mutable data will likely need to send Notifications and thus will likely want to fetch a reference to the Facade during their construction.
Initialize the View.
Called by the initialize_facade method. Override this method in your subclass of Facade if one or both of the following are true:
If you don‘t want to initialize a different View, call super at the beginning of your method, then register Mediator instances.
Note: This method is rarely overridden; in practice you are more likely to use a Command to create and register Mediators with the View, since Mediator instances will need to send Notifications and thus will likely want to fetch a reference to the Facade during their construction.
Notify Observers.
This method is left public mostly for backward compatibility, and to allow you to send custom notification classes using the facade.
Usually you should just call send_notification and pass the parameters, never having to construct the notification yourself.
Register an Command with the Controller by Notification name.
Remove a previously registered Command to Notification mapping from the Controller.
Create and send a Notification.
Keeps us from having to construct new notification instances in our implementation code.