Class: CSEmitter

Defined in: lib/emitter.coffee
Inherits: CSObject

Overview

abstract class CSEmitter for child class

Instance Method Summary

Inherited Method Summary

Methods inherited from CSObject

#destructor

Constructor Details

# (void) constructor(list)

This method is abstract.

Init map by array of emit names

Parameters:

  • list ( Array<String> ) is array of natural events

Throws:

  • ( TypeError ) — if call from new

Instance Method Details

# (null) destructor()

destructor clear all handlers, and clean map and links

Returns:

  • null

# (CSEmitter) on(name, handler)

Add event listener handler by name event.

@callback CSEvent call with CSEvent object

Parameters:

  • name ( String ) name of a event handle that
  • handler ( Function ) function, call when fired event

Throws:

  • ( Error ) — if no arguments
  • ( TypeError ) — if name not a String or handler not a Function
  • ( TypeError ) — if handler not passed

Returns:

# (CSEmitter|null) off(name, handler)

Remove listener handler for event name by this object. If handler not passed, remove all handlers by name event type. Return null if handler not found.

Parameters:

  • name ( String ) string, name of disable events
  • handler ( Function ) function, if pass argument, clear only handler

Throws:

  • ( Error ) — if no arguments
  • ( TypeError ) — if name not a String or handler not a Function
  • ( Error ) — if name is unknown type event

Returns:

  • ( CSEmitter|null ) — this or handler not found indicator

# (CSEmitter) once(name, handler)

Same as the on, but handler call only one and before regular handlers

Parameters:

  • `name` ( String ) string
  • handler ( Function ) listener

Throws:

  • ( Error ) — if no arguments
  • ( TypeError ) — if name not a String or handler not a Function
  • ( TypeError ) — if handler not pass

Returns:

# (Object<__DedicatedArray, CSEvent>) emit(nameOrEvent)

This method is abstract.

Emit event by name or by event. if nameOrEvent is string than CSEvent create by func without value

Parameters:

  • nameOrEvent ( String|CSEvent ) type event or event (CSEvent)

Throws:

  • ( Error ) — if call without realisation
  • ( TypeError ) — if nameOrEvent unknown type
  • ( Error ) — if try call unknown name of event

Returns:

  • ( Object<__DedicatedArray, CSEvent> ) — for internal usage

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: