Classes
The following classes are available globally.
-
A Multiton
IController
implementation.In PureMVC, the
Controller
class 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
.
Your application must register
ICommands
with the Controller.The simplest way is to subclass
Facade
, and use itsinitializeController
method to add your registrations.@see org.puremvc.swift.multicore.core.View View
@see org.puremvc.swift.multicore.patterns.observer.Observer Observer
@see org.puremvc.swift.multicore.patterns.observer.Notification Notification
@see org.puremvc.swift.multicore.patterns.command.SimpleCommand SimpleCommand
See more@see org.puremvc.swift.multicore.patterns.command.MacroCommand MacroCommand
Declaration
Swift
open class Controller : IController
- Remembering which
-
A Multiton
IModel
implementation.In PureMVC, the
Model
class provides access to model objects (Proxies) by named lookup.The
Model
assumes these responsibilities:- Maintain a cache of
IProxy
instances. - Provide methods for registering, retrieving, and removing
IProxy
instances.
Your application must register
IProxy
instances with theModel
. Typically, you use anICommand
to create and registerIProxy
instances once theFacade
has initialized the Core actors.@see org.puremvc.swift.multicore.patterns.proxy.Proxy Proxy
See more@see org.puremvc.swift.multicore.interfaces.IProxy IProxy
Declaration
Swift
open class Model : IModel
- Maintain a cache of
-
A Multiton
IView
implementation.In PureMVC, the
View
class assumes these responsibilities:- Maintain a cache of
IMediator
instances. - Provide methods for registering, retrieving, and removing
IMediators
. - Notifiying
IMediators
when they are registered or removed. - 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.multicore.patterns.mediator.Mediator Mediator
@see org.puremvc.swift.multicore.patterns.observer.Observer Observer
See more@see org.puremvc.swift.multicore.patterns.observer.Notification Notification
Declaration
Swift
open class View : IView
- Maintain a cache of
-
A base
ICommand
implementation that executes otherICommand
s.A
MacroCommand
maintains an list ofICommand
Class references called SubCommands.When
execute
is called, theMacroCommand
retrievesICommands
by executing closures and then callsexecute
on each of its SubCommands turn. Each SubCommand will be passed a reference to the originalINotification
that was passed to theMacroCommand
‘sexecute
method.Unlike
SimpleCommand
, your subclass should not overrideexecute
, but instead, should override theinitializeMacroCommand
method, callingaddSubCommand
once for each SubCommand to be executed.@see org.puremvc.swift.multicore.core.Controller Controller
@see org.puremvc.swift.multicore.patterns.observer.Notification Notification
See more@see org.puremvc.swift.multicore.patterns.command.SimpleCommand SimpleCommand
-
A base
ICommand
implementation.Your subclass should override the
execute
method where your business logic will handle theINotification
.@see org.puremvc.swift.multicore.core.Controller Controller
@see org.puremvc.swift.multicore.patterns.observer.Notification Notification
See more@see org.puremvc.swift.multicore.patterns.command.MacroCommand MacroCommand
-
A base
INotification
implementation.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/Apollo. 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 more@see org.puremvc.swift.multicore.patterns.observer.Observer Observer
*Declaration
Swift
open class Notification : INotification
-
A Base
INotifier
implementation.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, provides an initialized reference to theFacade
Multiton, 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.NOTE: In the MultiCore version of the framework, there is one caveat to notifiers, they cannot send notifications or reach the facade until they have a valid multitonKey.
The multitonKey is set:
- on a Command when it is executed by the Controller
- on a Mediator is registered with the View
- on a Proxy is registered with the Model.
@see org.puremvc.swift.multicore.patterns.proxy.Proxy Proxy
@see org.puremvc.swift.multicore.patterns.facade.Facade Facade
@see org.puremvc.swift.multicore.patterns.mediator.Mediator Mediator
@see org.puremvc.swift.multicore.patterns.command.MacroCommand MacroCommand
See more@see org.puremvc.swift.multicore.patterns.command.SimpleCommand SimpleCommand
Declaration
Swift
open class Notifier : INotifier
-
A base
IObserver
implementation.An
Observer
is an object that encapsulates information about an interested object with a method that should be called when a particularINotification
is broadcast.In PureMVC, the
Observer
class assumes these responsibilities:- Encapsulate the notification (callback) method of the interested object.
- Encapsulate the notification context (this) of the interested object.
- Provide methods for setting the notification method and context.
- Provide a method for notifying the interested object.
@see org.puremvc.swift.multicore.core.View View
See more@see org.puremvc.swift.multicore.patterns.observer.Notification Notification
Declaration
Swift
open class Observer : IObserver
-
A base
IProxy
implementation.In PureMVC,
Proxy
classes are used to manage parts of the application’s data model.A
Proxy
might simply manage a reference to a local data object, in which case interacting with it might involve setting and getting of its data in synchronous fashion.Proxy
classes are also used to encapsulate the application’s interaction with remote services to save or retrieve data, in which case, we adopt an asyncronous idiom; setting data (or calling a method) on theProxy
and listening for aNotification
to be sent when theProxy
has retrieved the data from the service.
See more@see org.puremvc.swift.multicore.core.Model Model