IController
public protocol IController
The interface definition for a PureMVC Controller.
In PureMVC, an IController
implementor
follows the ‘Command and Controller’ strategy, and
assumes these responsibilities:
- Remembering which
ICommand
s are intended to handle whichINotifications
. - Registering itself as an
IObserver
with theView
for eachINotification
that it has anICommand
mapping for. - Creating a new instance of the proper
ICommand
to handle a givenINotification
when notified by theView
. - Calling the
ICommand
‘sexecute
method, passing in theINotification
.
@see org.puremvc.swift.multicore.interfaces INotification
@see org.puremvc.swift.multicore.interfaces ICommand
-
Initialize the
Controller
instance.Declaration
Swift
func initializeController()
-
Register a particular
ICommand
class as the handler for a particularINotification
.Declaration
Swift
func registerCommand(_ notificationName: String, factory: @escaping () -> ICommand)
Parameters
notificationName
the name of the
INotification
closure
reference that returns
ICommand
-
Execute the
ICommand
previously registered as the handler forINotification
s with the given notification name.Declaration
Swift
func executeCommand(_ notification: INotification)
Parameters
notification
the
INotification
to execute the associatedICommand
for -
Check if a Command is registered for a given Notification
Declaration
Swift
func hasCommand(_ notificationName: String) -> Bool
Parameters
notificationName
Return Value
whether a Command is currently registered for the given
notificationName
. -
Remove a previously registered
ICommand
toINotification
mapping.Declaration
Swift
func removeCommand(_ notificationName: String)
Parameters
notificationName
the name of the
INotification
to remove theICommand
mapping for