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.
[Mediator]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 observe -
callback
function The callback to call for this colleague -
channel
string The Channel to add the pubished events to -
identifier
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 observe -
channel
string The Channel to add the pubished events to -
identifier
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 observe -
callback
function The callback to call on channel event -
channel
string The Channel events are pubished to -
identifier
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 observe -
channel
string The Channel events are pubished to -
identifier
string The identifier for this function
Returns string The identifier
subscribe
Subscribe to a channel
Parameters
-
channel
string The Channel events are pubished to -
callback
function The callback to call on channel event -
context
object The context (or 'this') -
once
boolean Toggle to set subscribe only once -
identifier
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 to -
args
...any -
N
object Extra parameter to pass to handler
Returns string The channel
unsubscribe
Cancel subscription
Parameters
-
channel
string The Channel events are pubished to -
callback
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 to -
subscription
string The subscription to subscribe to -
context
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/>
- mediator - A mediator for this view
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