presentation-mediator
v3.0.3
Published
The Augmented.js Next - Presentation Mediator Module.
Downloads
36
Maintainers
Readme
presentation-mediator
Augmented.js Presentation Mediator Module
API
Table of Contents
- Mediator
- Colleague
Mediator
Extends Colleague
Mediator View - The mediator in the Mediator Pattern The mediator defines the interface for communication between colleague views. Loose coupling between colleague objects is achieved by having colleagues communicate with the Mediator, rather than with each other.
Parameters
options
object Options to set
delegateEvents
Extend delegateEvents() to set subscriptions
Parameters
events
event
array The events to undelegate
Returns array the events
undelegateEvents
Extend undelegateEvents() to unset subscriptions
Parameters
events
event
array The events to undelegate
Returns array the events
subscriptions
Subscriptions
Properties
subscriptions
array
unsetSubscriptions
Unsubscribe to each subscription
Parameters
subscriptions
Object An optional hash of subscription to remove
Returns array subscriptions
observeColleague
Observe a Colleague View - observe a Colleague and add to a channel
Parameters
colleague
Colleague The Colleague to observecallback
function The callback to call for this colleaguechannel
string The Channel to add the pubished events toidentifier
string The identifier for this function
Returns string The identifier
observeColleagueAndTrigger
Observe a Colleague View - observe a Colleague and add to a channel and auto trigger events
Parameters
colleague
Colleague The Colleague to observechannel
string The Channel to add the pubished events toidentifier
string The identifier for this function
Returns string The identifier
dismissColleague
Dismiss a Colleague View - Remove a Colleague from the channel
Parameters
colleague
Presentation.Colleague The Colleague to observecallback
function The callback to call on channel eventchannel
string The Channel events are pubished toidentifier
string The identifier for this function
Returns string The identifier
dismissColleagueTrigger
Dismiss a Colleague View - Remove a Colleague from the channel that has an auto trigger
Parameters
colleague
Colleague The Colleague to observechannel
string The Channel events are pubished toidentifier
string The identifier for this function
Returns string The identifier
subscribe
Subscribe to a channel
Parameters
channel
string The Channel events are pubished tocallback
function The callback to call on channel eventcontext
object The context (or 'this')once
boolean Toggle to set subscribe only onceidentifier
string The identifier for this function
Returns string The identifier
publish
Trigger all callbacks for a channel
Parameters
channel
string The Channel events are pubished toargs
...anyN
object Extra parameter to pass to handler
Returns string The channel
unsubscribe
Cancel subscription
Parameters
channel
string The Channel events are pubished tocallback
function The function callback registered (unused)context
object The context (or 'this')identifier
string The identifier for this function
Returns string The channel
subscribeOnce
Subscribing to one event only
Parameters
channel
string The Channel events are pubished tosubscription
string The subscription to subscribe tocontext
object The context (or 'this')identifier
string The identifier for this function
Returns string The identifier
getColleagues
Get All the Colleagues for a channel
Parameters
channel
string The Channel events are pubished to
Returns array The colleagues for a channel
channels
Property for Channels
Properties
channels
array
getChannel
Get a specific channel
Parameters
channel
string The Channel events are pubished to
Returns array Returns the requested channel or null if nothing exists
defaultChannel
Get the default channel Convenience method for _.channel = null;
Properties
Returns
array the default channel or null if nothing exists
defaultIdentifier
Get the default identifier
Properties
Returns
string the default identifier
Colleague
Extends View
Colleague View — The 'child' view. The Colleague communicates with other Colleagues through its Mediator. Supported options:</br/>
Parameters
options
object Options to pass
sendMessage
Send a message to the mediator's queue
Parameters
Returns string Message sent
setMediatorMessageQueue
Set the mediator to this colleague
Parameters
mediator
Mediator The mediator
Returns Mediator The mediator
Meta
- deprecated: set with: this.mediator = ...
removeMediatorMessageQueue
Remove the mediator from this colleague
Returns boolean true
mediator
Property of the mediator
Properties
mediator
Mediator