Protocols
The following protocols are available globally.
-
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.interfaces INotification
See more@see org.puremvc.swift.interfaces ICommand
Declaration
Swift
public protocol IController
- Remembering which
-
The interface definition for a PureMVC Facade.
The Facade Pattern suggests providing a single class to act as a central point of communication for a subsystem.
In PureMVC, the Facade acts as an interface between the core MVC actors (Model, View, Controller) and the rest of your application.
@see org.puremvc.swift.interfaces.IModel IModel
@see org.puremvc.swift.interfaces.IView IView
@see org.puremvc.swift.interfaces.IController IController
@see org.puremvc.swift.interfaces.ICommand ICommand
See more@see org.puremvc.swift.interfaces.INotification INotification
Declaration
Swift
public protocol IFacade : INotifier
-
The interface definition for a PureMVC Mediator.
In PureMVC,
IMediator
implementors assume these responsibilities:- Implement a common method which returns a list of all
INotification
s theIMediator
has interest in. - Implement a notification callback method.
- Implement methods that are called when the IMediator is registered or removed from the View.
Additionally,
IMediator
s typically:- Act as an intermediary between one or more view components such as text boxes or list controls, maintaining references and coordinating their behavior.
- In Flash-based apps, this is often the place where event listeners are added to view components, and their handlers implemented.
- Respond to and generate
INotifications
, interacting with of the rest of the PureMVC app.
When an
IMediator
is registered with theIView
, theIView
will call theIMediator
‘slistNotificationInterests
method. TheIMediator
will return anArray
ofINotification
names which it wishes to be notified about.The
IView
will then create anObserver
object encapsulating thatIMediator
’s (handleNotification
) method and register it as an Observer for eachINotification
name returned bylistNotificationInterests
.`@see org.puremvc.swift.interfaces.INotification INotification
See moreDeclaration
Swift
public protocol IMediator : INotifier
- Implement a common method which returns a list of all
-
The interface definition for a PureMVC Model.
In PureMVC,
IModel
implementors provide access toIProxy
objects by named lookup.An
IModel
assumes these responsibilities:- Maintain a cache of
IProxy
instances - Provide methods for registering, retrieving, and removing
IProxy
instances
Declaration
Swift
public protocol IModel
- Maintain a cache of
-
The interface definition for a PureMVC Notification.
PureMVC does not rely upon underlying event models such as the one provided with Flash, and ActionScript 3 does not have an inherent event model.
The Observer Pattern as implemented within PureMVC exists to support event-driven communication between the application and the actors of the MVC triad.
Notifications are not meant to be a replacement for Events in Flex/Flash/AIR. Generally,
IMediator
implementors place event listeners on their view components, which they then handle in the usual way. This may lead to the broadcast ofNotification
s to triggerICommand
s or to communicate with otherIMediators
.IProxy
andICommand
instances communicate with each other andIMediator
s by broadcastingINotification
s.A key difference between Flash
Event
s and PureMVCNotification
s is thatEvent
s follow the ‘Chain of Responsibility’ pattern, ‘bubbling’ up the display hierarchy until some parent component handles theEvent
, while PureMVCNotification
s follow a ‘Publish/Subscribe’ pattern. PureMVC classes need not be related to each other in a parent/child relationship in order to communicate with one another usingNotification
s.@see org.puremvc.swift.interfaces.IView IView
See more@see org.puremvc.swift.interfaces.IObserver IObserver
Declaration
Swift
public protocol INotification
-
The interface definition for a PureMVC Notifier.
MacroCommand, Command, Mediator
andProxy
all have a need to sendNotifications
.The
INotifier
interface provides a common method calledsendNotification
that relieves implementation code of the necessity to actually constructNotifications
.The
Notifier
class, which all of the above mentioned classes extend, also provides an initialized reference to theFacade
Singleton, which is required for the convienience method for sendingNotifications
, but also eases implementation as these classes have frequentFacade
interactions and usually require access to the facade anyway.@see org.puremvc.swift.interfaces.IFacade IFacade
See more@see org.puremvc.swift.interfaces.INotification INotification
Declaration
Swift
public protocol INotifier
-
The interface definition for a PureMVC Observer.
In PureMVC,
IObserver
implementors assume these responsibilities:- Encapsulate the notification (callback) method of the interested object.
- Encapsulate the notification context (self) of the interested object.
- Provide methods for setting the interested object’ notification method and context.
- Provide a method for notifying the interested object.
PureMVC does not rely upon underlying event models such as the one provided with Flash, and ActionScript 3 does not have an inherent event model.
The Observer Pattern as implemented within PureMVC exists to support event driven communication between the application and the actors of the MVC triad.
An Observer is an object that encapsulates information about an interested object with a notification method that should be called when an
INotification
is broadcast. The Observer then acts as a proxy for notifying the interested object.Observers can receive
Notification
s by having theirnotifyObserver
method invoked, passing in an object implementing theINotification
interface, such as a subclass ofNotification
.@see org.puremvc.swift.interfaces.IView IView
See more@see org.puremvc.swift.interfaces.INotification INotification
Declaration
Swift
public protocol IObserver
-
The interface definition for a PureMVC Proxy.
In PureMVC,
IProxy
implementors assume these responsibilities:- Implement a common method which returns the name of the Proxy.
- Provide methods for setting and getting the data object.
Additionally,
IProxy
s typically:- Maintain references to one or more pieces of model data.
- Provide methods for manipulating that data.
- Generate
INotifications
when their model data changes. - Expose their name as a
public static const
calledNAME
, if they are not instantiated multiple times. - Encapsulate interaction with local or remote services used to fetch and persist model data.
Declaration
Swift
public protocol IProxy : INotifier
-
The interface definition for a PureMVC View.
In PureMVC,
IView
implementors assume these responsibilities:In PureMVC, the
View
class assumes these responsibilities:- Maintain a cache of
IMediator
instances. - Provide methods for registering, retrieving, and removing
IMediators
. - Managing the observer lists for each
INotification
in the application. - Providing a method for attaching
IObservers
to anINotification
‘s observer list. - Providing a method for broadcasting an
INotification
. - Notifying the
IObservers
of a givenINotification
when it broadcast.
@see org.puremvc.swift.interfaces.IMediator IMediator
@see org.puremvc.swift.interfaces.IObserver IObserver
See more@see org.puremvc.swift.interfaces.INotification INotification
Declaration
Swift
public protocol IView
- Maintain a cache of