Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shalimov/jsmediator


https://github.com/shalimov/jsmediator

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# DOC IN PROGRESS
# Pls, look at the tests for examples


## global : object
**Kind**: global namespace

* [Mediator](#global.Mediator)
* [new Mediator(eventEmitter, setting)](#new_global.Mediator_new)
* _instance_
* [.addComponent(name, registrator)](#global.Mediator+addComponent)
* [.removeComponent(name)](#global.Mediator+removeComponent) ⇒ boolean
* [.hasComponent(name)](#global.Mediator+hasComponent) ⇒ boolean
* [.getComponent(name)](#global.Mediator+getComponent) ⇒ Object
* [.componentsList()](#global.Mediator+componentsList) ⇒ Array
* [.shareResponsibility(mediator)](#global.Mediator+shareResponsibility)
* [.toString()](#global.Mediator+toString) ⇒ string
* _static_
* [.EVENTS](#global.Mediator.EVENTS)
* [.ADD](#global.Mediator.EVENTS.ADD)
* [.REMOVE](#global.Mediator.EVENTS.REMOVE)


#### new Mediator(eventEmitter, setting)
Mediator - Provide ability to you create a simple mediator to control interaction among components based on low coupling

| Param | Type |
| --- | --- |
| eventEmitter | EventEmitter |
| setting | Object |


#### mediator.addComponent(name, registrator)
Method provides ability to add component

**Kind**: instance method of [Mediator](#global.Mediator)

| Param | Type |
| --- | --- |
| name | string |
| registrator | function |


#### mediator.removeComponent(name) ⇒ boolean
Method removes existing component, unattached event handlers for component and remove dependencies

**Kind**: instance method of [Mediator](#global.Mediator)
**Returns**: boolean - True if component was removed in opposite false

| Param | Type | Description |
| --- | --- | --- |
| name | string | Component Name |


#### mediator.hasComponent(name) ⇒ boolean
Method provides you ability to check component existence by name

**Kind**: instance method of [Mediator](#global.Mediator)

| Param | Type |
| --- | --- |
| name | string |


#### mediator.getComponent(name) ⇒ Object
Method provides component by name

**Kind**: instance method of [Mediator](#global.Mediator)

| Param | Type |
| --- | --- |
| name | string |


#### mediator.componentsList() ⇒ Array
Method provides components' names list for all registered components

**Kind**: instance method of [Mediator](#global.Mediator)
**Returns**: Array - Array that contains string names of each registered component

#### mediator.shareResponsibility(mediator)
Method can be used if you want to share events among several mediators in application

**Kind**: instance method of [Mediator](#global.Mediator)

| Param | Type |
| --- | --- |
| mediator | Mediator |


#### mediator.toString() ⇒ string
Return string for Instance of Mediator [object Mediator]

**Kind**: instance method of [Mediator](#global.Mediator)

#### Mediator.EVENTS
**Kind**: static constant of [Mediator](#global.Mediator)

* [.EVENTS](#global.Mediator.EVENTS)
* [.ADD](#global.Mediator.EVENTS.ADD)
* [.REMOVE](#global.Mediator.EVENTS.REMOVE)


##### EVENTS.ADD
Event with this name is emitted every time when new component is registered in system

**Kind**: static constant of [EVENTS](#global.Mediator.EVENTS)

##### EVENTS.REMOVE
Event with this name is emitted every time when component is removed in system

**Kind**: static constant of [EVENTS](#global.Mediator.EVENTS)