Framework

- About
- Guides
- Community
- API
- Code
- Download

# Kanso API Documentation

Index | View on single page

## events

The events module handles events emitted by Kanso as well as custom events defined by a Kanso app. These events can be used client-side or server-side. Although you are limited to synchronous operation on the server, so events are less likely to be useful there.

### on(name, listener)

Adds a listener function for the given event name.

#### Parameters

name | String |
listener | Function |

### once(name, listener)

Binds an event listener to the given event name, but unbinds it after its first invocation.

#### Parameters

name | String |
listener | Function |

### emit(name, [...])

Triggers any event listeners bound to the given event name. Listeners are called in the order they were bound. If a listener returns false subsequent event listeners in the chain are not called.

The first argument is the event name to emit any additional arguments are used as arguments to the bound event listeners.

#### Parameters

name | String |
... |  |

### listeners(name)

Returns an array of the bound event listeners for the given event name. If no events are bound, an empty array is returned.

#### Parameters

name | String |

Returns: Array

### removeAllListeners(name)

Removes all bound event listeners for a given event name.

#### Parameters

name | String |

### removeListener(name, listener)

Removes a specific event listener for a given event name.

#### Parameters

name | String |
listener | Function |