API Docs for:
Show:

LEvent Class

Defined in: ../src/levent.js:5

LEvent is a lightweight events library focused in low memory footprint and fast delivery. It works by creating a property called "__levents" inside the object that has the bindings, and storing arrays with all the bindings.

Constructor

LEvent

()

Defined in ../src/levent.js:5

Methods

LEvent.bind

(
  • instance
  • event_name
  • callback
  • target_instance
)

Defined in ../src/levent.js:14

Binds an event to an instance

Parameters:

  • instance Object

    where to attach the event

  • event_name String

    string defining the event name

  • callback Function

    function to call when the event is triggered

  • target_instance Object

    [Optional] instance to call the function (use this instead of .bind method to help removing events)

LEvent.extendClass

(
  • constructor
)

Adds the methods to bind, trigger and unbind to this class prototype

Parameters:

  • constructor Object

LEvent.hasBind

(
  • instance
  • event_name
)
Boolean

Tells if there is any callback binded to this event

Parameters:

  • instance Object

    where the are the events binded

  • event_name String

    string defining the event name

Returns:

Boolean:

true is there is at least one

LEvent.hasBindTo

(
  • instance
  • target
)
Boolean

Tells if there is any callback binded to this object pointing to a method in the target object

Parameters:

  • instance Object

    where there are the events binded

  • target Object

    instance to check to

Returns:

Boolean:

true is there is at least one

LEvent.isBind

(
  • instance
  • event_name
  • callback
  • target_instance
)

Tells if there is a binded callback that matches the criteria

Parameters:

  • instance Object

    where the are the events binded

  • event_name String

    string defining the event name

  • callback Function

    the callback

  • target_instance Object

    [Optional] instance binded to callback

LEvent.trigger

(
  • instance
  • event_name
  • parameters
  • reverse_order
)

Triggers and event in an instance

Parameters:

  • instance Object

    that triggers the event

  • event_name String

    string defining the event name

  • parameters

    that will be received by the binded function

  • reverse_order Bool

    trigger in reverse order (binded last get called first)

LEvent.triggerArray

(
  • array
  • event_name
  • parameters
  • reverse_order
)

Triggers and event to every element in an array

Parameters:

  • array Array

    contains all instances to triggers the event

  • event_name String

    string defining the event name

  • parameters

    that will be received by the binded function

  • reverse_order Bool

    trigger in reverse order (binded last get called first)

LEvent.unbind

(
  • instance
  • event_name
  • callback
  • target_instance
)

Defined in ../src/levent.js:46

Unbinds an event from an instance

Parameters:

  • instance Object

    where the event is binded

  • event_name String

    string defining the event name

  • callback Function

    function that was binded

  • target_instance Object

    [Optional] target_instance that was binded

LEvent.unbindAll

(
  • instance
  • target_instance
)

Defined in ../src/levent.js:87

Unbinds all events from an instance (or the ones that match certain target_instance)

Parameters:

  • instance Object

    where the events are binded

  • target_instance Object

    [Optional] target_instance of the events to remove

LEvent.unbindAll

(
  • instance
  • event
)

Unbinds all callbacks associated to one specific event from this instance

Parameters:

  • instance Object

    where the events are binded

  • event String

    name of the event you want to remove all binds