Class: tinymce.util.Dispatcher

# tinymce.util.Dispatcher

Namespace | tinymce.util
Class | Dispatcher

This class is used to dispatch event to observers/listeners. All internal events inside TinyMCE uses this class.

## Public Methods

Method | Defined By
--- | ---
Dispatcher(s:Object) Constructs a new event dispatcher object. | Dispatcher
add(cb:function, s:Object):function Add an observer function to be executed when a dispatch call is done. | Dispatcher
addToTop(cb:function, s:Object):function Add an observer function to be executed to the top of the list of observers. | Dispatcher
dispatch(..:Object):Object Dispatches an event to all observers/listeners. | Dispatcher
remove(cb:function):function Removes an observer function. | Dispatcher

## Method details

### Dispatcherconstructor

`public function Dispatcher(s:Object)`
Constructs a new event dispatcher object.

#### Parameters

s:Object | Optional default execution scope for all observer functions.

### addmethod

`public function add(cb:function, s:Object):function`
Add an observer function to be executed when a dispatch call is done.

#### Parameters

cb:function | Callback function to execute when a dispatch event occurs.
s:Object | Optional execution scope, defaults to the one specified in the class constructor.

#### Returns

function - Returns the same function as the one passed on.

### addToTopmethod

`public function addToTop(cb:function, s:Object):function`
Add an observer function to be executed to the top of the list of observers.

#### Parameters

cb:function | Callback function to execute when a dispatch event occurs.
s:Object | Optional execution scope, defaults to the one specified in the class constructor.

#### Returns

function - Returns the same function as the one passed on.

### dispatchmethod

`public function dispatch(..:Object):Object`
Dispatches an event to all observers/listeners.

#### Parameters

..:Object | Any number of arguments to dispatch.

#### Returns

Object - Last observer functions return value.

### removemethod

`public function remove(cb:function):function`
Removes an observer function.

#### Parameters

cb:function | Observer function to remove.

#### Returns

function - The same function that got passed in or null if it wasn't found.