Documentation
¶
Index ¶
- type Notification
- type Observer
- func (self *Observer) CompareNotifyContext(object interface{}) bool
- func (self *Observer) NotifyObserver(notification interfaces.INotification)
- func (self *Observer) SetNotifyContext(notifyContext interface{})
- func (self *Observer) SetNotifyMethod(notifyMethod func(notification interfaces.INotification))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Notification ¶
type Notification struct {
// contains filtered or unexported fields
}
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 of Notifications to trigger ICommands or to communicate with other IMediators. IProxy and ICommand instances communicate with each other and IMediators by broadcasting INotifications.
A key difference between Flash Events and PureMVC Notifications is that Events follow the 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy until some parent component handles the Event, while PureMVC Notifications 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 using Notifications.
func NewNotification ¶
func NewNotification(name string, body interface{}, _type string) *Notification
Constructor.
- parameter name: name of the Notification instance. (required)
- parameter body: the Notification body. (optional)
- parameter type: the type of the Notification
func (*Notification) Body ¶
func (self *Notification) Body() interface{}
Get the body of notification instance
func (*Notification) Name ¶
func (self *Notification) Name() string
Get the name of notification instance
func (*Notification) SetBody ¶
func (self *Notification) SetBody(body interface{})
Set the body of notification instance
func (*Notification) SetType ¶
func (self *Notification) SetType(t string)
Set the type of notification instance
func (*Notification) String ¶
func (self *Notification) String() string
Get the string representation of the Notification instance.
- returns: the string representation of the Notification instance.
func (*Notification) Type ¶
func (self *Notification) Type() string
Get the type of notification instance
type Observer ¶
type Observer struct {
Notify func(notification interfaces.INotification)
Context interface{}
}
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 particular INotification 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.
func (*Observer) CompareNotifyContext ¶
Compare an object to the notification context.
- parameter object: the object to compare - returns: boolean indicating if the object and the notification context are the same
func (*Observer) NotifyObserver ¶
func (self *Observer) NotifyObserver(notification interfaces.INotification)
Notify the interested object.
- parameter notification: the INotification to pass to the interested object's notification method.
func (*Observer) SetNotifyContext ¶
func (self *Observer) SetNotifyContext(notifyContext interface{})
Set the notification context.
func (*Observer) SetNotifyMethod ¶
func (self *Observer) SetNotifyMethod(notifyMethod func(notification interfaces.INotification))
Set the notification method.