1.0.0 • Published 8 years ago

@kempo/edo v1.0.0

Weekly downloads
-
License
CC-BY-NC-SA-3.0
Repository
github
Last release
8 years ago

EDO

Event Driven Object

Constructor

new EDO()

Creates a new EDO object.

Members

ready: bool

Indicates if the ready event has been triggered yet.

Methods

on(events, handler): this

Start listening for events.

  • events: string - A space delimited list of events to start listening for.
  • handler: function - A function to be called when the events occur. This function accepts two parameters, the first is the event that occured and the second is the event_data passed to the trigger.
once(events, handler): this

Starts listening for events to occur one time. Once the event occurs the handler will be automatically removed.

  • events: string - A space delimited list of events to start listening for.
  • handler: function - A function to be called when the events occur. This function accepts two parameters, the first is the event that occured and the second is the event_data passed to the trigger.
off(events, handler): this

Stop listening for events.

  • events: string - A space delimited list of events to stop listening for.
  • handler: function - The handler to stop calling when the event occurs.
off(events): this

Stop listening for events.

  • events: string - A space delimited list of events to stop listening for.
off(handler): this

Stop listening for events.

  • handler: function - The handler to stop calling when the event occurs.
trigger(events, event_data): this

Trigger an event within the object.

  • events: string - A space delimited list of events to trigger.
  • event_data: anything - Some data to pass to the event handlers about this event occurance.

Special ready Event

The ready event is treated different than all other in a few ways.

  1. The ready event can only be triggered once. All subsequent ready events will be ignored.
  2. If a ready event has already been triggered and an on or once method call targets the ready event, the handler will be called immediately with the event_data of the previous ready event.
  3. The ready member is false until a ready event is triggered, then it becomes true and can never become change again.
  • Setting the ready member to true will automatically trigger a ready event with no event_data.
1.0.0

8 years ago