Facade
open class Facade : IFacade
A base Multiton IFacade implementation.
@see org.puremvc.swift.multicore.core.Model Model
@see org.puremvc.swift.multicore.core.View View
@see org.puremvc.swift.multicore.core.Controller Controller
-
Constructor.
This
IFacadeimplementation is a Multiton, so you should not call the constructor directly, but instead call the static Factory method, passing the unique key for this instance and the closure reference that returns theIFacadeimplementation.Facade.getInstance( multitonKey ) { Facade(key: multitonKey) }@throws Error Error if instance for this Multiton key has already been constructed
Declaration
Swift
public init(key: String) -
Initialize the Multiton
Facadeinstance.Called automatically by the constructor. Override in your subclass to do any subclass specific initializations. Be sure to call
super.initializeFacade(), though.Declaration
Swift
open func initializeFacade() -
Initialize the
Controller.Called by the
initializeFacademethod. Override this method in your subclass ofFacadeif one or both of the following are true:- You wish to initialize a different
IController. - You have
Commandsto register with theControllerat startup.`.
If you don’t want to initialize a different
IController, callsuper.initializeController()at the beginning of your method, then registerCommands.Declaration
Swift
open func initializeController() - You wish to initialize a different
-
Initialize the
Model.Called by the
initializeFacademethod. Override this method in your subclass ofFacadeif one or both of the following are true:- You wish to initialize a different
IModel. - You have
Proxys to register with the Model that do not retrieve a reference to the Facade at construction time.`
If you don’t want to initialize a different
IModel, callsuper.initializeModel()at the beginning of your method, then registerProxys.Note: This method is rarely overridden; in practice you are more likely to use a
Commandto create and registerProxys with theModel, sinceProxys with mutable data will likely need to sendINotifications and thus will likely want to fetch a reference to theFacadeduring their construction.Declaration
Swift
open func initializeModel() - You wish to initialize a different
-
Initialize the
View.Called by the
initializeFacademethod. Override this method in your subclass ofFacadeif one or both of the following are true:If you don’t want to initialize a different
IView, callsuper.initializeView()at the beginning of your method, then registerIMediatorinstances.Note: This method is rarely overridden; in practice you are more likely to use a
Commandto create and registerMediators with theView, sinceIMediatorinstances will need to sendINotifications and thus will likely want to fetch a reference to theFacadeduring their construction.Declaration
Swift
open func initializeView() -
Register an
ICommandwith theControllerby Notification name.Declaration
Swift
open func registerCommand(_ notificationName: String, closure: @escaping () -> ICommand)Parameters
notificationNamethe name of the
INotificationto associate theICommandwithclosurereference that returns
ICommand -
Check if a Command is registered for a given Notification
Declaration
Swift
open func hasCommand(_ notificationName: String) -> BoolParameters
notificationNameReturn Value
whether a Command is currently registered for the given
notificationName. -
Remove a previously registered
ICommandtoINotificationmapping from the Controller.Declaration
Swift
open func removeCommand(_ notificationName: String)Parameters
notificationNamethe name of the
INotificationto remove theICommandmapping for -
Check if a Proxy is registered
Declaration
Swift
open func hasProxy(_ proxyName: String) -> BoolParameters
proxyNameReturn Value
whether a Proxy is currently registered with the given
proxyName. -
Check if a Mediator is registered or not
Declaration
Swift
open func hasMediator(_ mediatorName: String) -> BoolParameters
mediatorNameReturn Value
whether a Mediator is registered with the given
mediatorName. -
Create and send an
INotification.Keeps us from having to construct new notification instances in our implementation code.
Declaration
Swift
open func sendNotification(_ notificationName: String, body: Any, type: String)Parameters
notificationNamethe name of the notiification to send
bodythe body of the notification (
typethe type of the notification
-
Create and send an
INotification.Keeps us from having to construct new notification instances in our implementation code.
Declaration
Swift
open func sendNotification(_ notificationName: String, body: Any)Parameters
notificationNamethe name of the notiification to send
bodythe body of the notification (optional)
-
Create and send an
INotification.Keeps us from having to construct new notification instances in our implementation code.
Declaration
Swift
open func sendNotification(_ notificationName: String)Parameters
notificationNamethe name of the notiification to send
-
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 sendNotification and pass the parameters, never having to construct the notification yourself.
Declaration
Swift
open func notifyObservers(_ notification: INotification)Parameters
notificationthe
INotificationto have theViewnotifyObserversof. -
Set the Multiton key for this facade instance.
Not called directly, but instead from the constructor when getInstance is invoked. It is necessary to be public in order to implement INotifier.
Declaration
Swift
open func initializeNotifier(_ key: String) -
Check if a Core is registered or not
Declaration
Swift
open class func hasCore(_ key: String) -> BoolParameters
keythe multiton key for the Core in question
Return Value
whether a Core is registered with the given
key. -
Remove a Core.
Remove the Model, View, Controller and Facade instances for the given key.
Declaration
Swift
open class func removeCore(_ key: String)Parameters
keymultitonKey of the Core to remove
Facade Class Reference