Facade
open class Facade : IFacade
A base Multiton IFacade implementation.
@see org.puremvc.swift.core.model.Model Model
@see org.puremvc.swift.core.view.View View
@see org.puremvc.swift.core.controller.Controller Controller
@see org.puremvc.swift.patterns.observer.Notification Notification
@see org.puremvc.swift.patterns.mediator.Mediator Mediator
@see org.puremvc.swift.patterns.proxy.Proxy Proxy
@see org.puremvc.swift.patterns.command.SimpleCommand SimpleCommand
@see org.puremvc.swift.patterns.command.MacroCommand MacroCommand
-
Constructor.
This
IFacadeimplementation is a Singleton, so you should not call the constructor directly, but instead call the static Singleton Factory method, passing the closure that returns theIFacadeimplementation.Facade.getInstance() { Facade() }@throws Error Error if Singleton instance has already been constructed
Declaration
Swift
public init() -
Initialize the Singleton
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 sendINotificationsand 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. -
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 sendNotification(_ notificationName: String, body: Any? = nil, type: String? = nil)Parameters
notificationthe
INotificationto have theViewnotifyObserversof. -
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.
Facade Class Reference