# presentation-mediator

Augmented.js Presentation Mediator Module

# API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

*   [Mediator](#mediator)
    *   [Parameters](#parameters)
    *   [delegateEvents](#delegateevents)
        *   [Parameters](#parameters-1)
    *   [undelegateEvents](#undelegateevents)
        *   [Parameters](#parameters-2)
    *   [subscriptions](#subscriptions)
        *   [Properties](#properties)
    *   [unsetSubscriptions](#unsetsubscriptions)
        *   [Parameters](#parameters-3)
    *   [observeColleague](#observecolleague)
        *   [Parameters](#parameters-4)
    *   [observeColleagueAndTrigger](#observecolleagueandtrigger)
        *   [Parameters](#parameters-5)
    *   [dismissColleague](#dismisscolleague)
        *   [Parameters](#parameters-6)
    *   [dismissColleagueTrigger](#dismisscolleaguetrigger)
        *   [Parameters](#parameters-7)
    *   [subscribe](#subscribe)
        *   [Parameters](#parameters-8)
    *   [publish](#publish)
        *   [Parameters](#parameters-9)
    *   [unsubscribe](#unsubscribe)
        *   [Parameters](#parameters-10)
    *   [subscribeOnce](#subscribeonce)
        *   [Parameters](#parameters-11)
    *   [getColleagues](#getcolleagues)
        *   [Parameters](#parameters-12)
    *   [channels](#channels)
        *   [Properties](#properties-1)
    *   [getChannel](#getchannel)
        *   [Parameters](#parameters-13)
    *   [defaultChannel](#defaultchannel)
        *   [Properties](#properties-2)
    *   [defaultIdentifier](#defaultidentifier)
        *   [Properties](#properties-3)
*   [Colleague](#colleague)
    *   [Parameters](#parameters-14)
    *   [sendMessage](#sendmessage)
        *   [Parameters](#parameters-15)
    *   [setMediatorMessageQueue](#setmediatormessagequeue)
        *   [Parameters](#parameters-16)
    *   [removeMediatorMessageQueue](#removemediatormessagequeue)
    *   [mediator](#mediator-1)
        *   [Properties](#properties-4)

## Mediator

**Extends Colleague**

Mediator View - The mediator in the Mediator Pattern<br/>
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.

<pre>
[Mediator]<-----[Colleague]
    ^-----------[Colleague]
</pre>

### Parameters

*   `options` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options to set

### delegateEvents

Extend delegateEvents() to set subscriptions

#### Parameters

*   `events`  
*   `event` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** The events to undelegate

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** the events

### undelegateEvents

Extend undelegateEvents() to unset subscriptions

#### Parameters

*   `events`  
*   `event` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** The events to undelegate

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** the events

### subscriptions

Subscriptions

#### Properties

*   `subscriptions` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** 

### unsetSubscriptions

Unsubscribe to each subscription

#### Parameters

*   `subscriptions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** An optional hash of subscription to remove

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** subscriptions

### observeColleague

Observe a Colleague View - observe a Colleague and add to a channel

#### Parameters

*   `colleague` **[Colleague](#colleague)** The Colleague to observe
*   `callback` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** The callback to call for this colleague
*   `channel` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The Channel to add the pubished events to
*   `identifier` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier for this function

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier

### observeColleagueAndTrigger

Observe a Colleague View - observe a Colleague and add to a channel and auto trigger events

#### Parameters

*   `colleague` **[Colleague](#colleague)** The Colleague to observe
*   `channel` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The Channel to add the pubished events to
*   `identifier` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier for this function

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier

### dismissColleague

Dismiss a Colleague View - Remove a Colleague from the channel

#### Parameters

*   `colleague` **Presentation.Colleague** The Colleague to observe
*   `callback` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** The callback to call on channel event
*   `channel` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The Channel events are pubished to
*   `identifier` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier for this function

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier

### dismissColleagueTrigger

Dismiss a Colleague View - Remove a Colleague from the channel that has an auto trigger

#### Parameters

*   `colleague` **[Colleague](#colleague)** The Colleague to observe
*   `channel` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The Channel events are pubished to
*   `identifier` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier for this function

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier

### subscribe

Subscribe to a channel

#### Parameters

*   `channel` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The Channel events are pubished to
*   `callback` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** The callback to call on channel event
*   `context` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The context (or 'this')
*   `once` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Toggle to set subscribe only once
*   `identifier` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier for this function

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier

### publish

Trigger all callbacks for a channel

#### Parameters

*   `channel` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The Channel events are pubished to
*   `args` **...any** 
*   `N` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Extra parameter to pass to handler

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The channel

### unsubscribe

Cancel subscription

#### Parameters

*   `channel` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The Channel events are pubished to
*   `callback` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** The function callback registered (unused)
*   `context` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The context (or 'this')
*   `identifier` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier for this function

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The channel

### subscribeOnce

Subscribing to one event only

#### Parameters

*   `channel` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The Channel events are pubished to
*   `subscription` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The subscription to subscribe to
*   `context` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The context (or 'this')
*   `identifier` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier for this function

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The identifier

### getColleagues

Get All the Colleagues for a channel

#### Parameters

*   `channel` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The Channel events are pubished to

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** The colleagues for a channel

### channels

Property for Channels

#### Properties

*   `channels` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** 

### getChannel

Get a specific channel

#### Parameters

*   `channel` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The Channel events are pubished to

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Returns the requested channel or null if nothing exists

### defaultChannel

Get the default channel<br/>
Convenience method for \_.channel = null;

#### Properties

*   `Returns` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** the default channel or null if nothing exists

### defaultIdentifier

Get the default identifier

#### Properties

*   `Returns` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the default identifier

## Colleague

**Extends View**

<em>Colleague View</em> — The 'child' view.<br/>
The Colleague communicates with other Colleagues through its Mediator.<br/>
Supported options:\</br/>

<ul>
<li>mediator - A mediator for this view</li>
</ul>

### Parameters

*   `options` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options to pass

### sendMessage

Send a message to the mediator's queue

#### Parameters

*   `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Message to send
*   `data` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Data to send with message

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Message sent

### setMediatorMessageQueue

Set the mediator to this colleague

#### Parameters

*   `mediator` **[Mediator](#mediator)** The mediator

Returns **[Mediator](#mediator)** The mediator

**Meta**

*   **deprecated**: set with: this.mediator = ...

### removeMediatorMessageQueue

Remove the mediator from this colleague

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true

### mediator

Property of the mediator

#### Properties

*   `mediator` **[Mediator](#mediator)** 
