LEvent Class
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
()
Item Index
Methods
LEvent.bind
-
instance
-
event_name
-
callback
-
target_instance
Binds an event to an instance
Parameters:
-
instance
Objectwhere to attach the event
-
event_name
Stringstring defining the event name
-
callback
Functionfunction 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
Tells if there is any callback binded to this event
Parameters:
-
instance
Objectwhere the are the events binded
-
event_name
Stringstring defining the event name
Returns:
true is there is at least one
LEvent.hasBindTo
-
instance
-
target
Tells if there is any callback binded to this object pointing to a method in the target object
Parameters:
-
instance
Objectwhere there are the events binded
-
target
Objectinstance to check to
Returns:
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
Objectwhere the are the events binded
-
event_name
Stringstring defining the event name
-
callback
Functionthe callback
-
target_instance
Object[Optional] instance binded to callback
LEvent.trigger
-
instance
-
event_name
-
parameters
-
reverse_order
-
expand_parameters
Triggers and event in an instance If the callback returns true then it will stop the propagation and return true
Parameters:
-
instance
Objectthat triggers the event
-
event_name
Stringstring defining the event name
-
parameters
that will be received by the binded function
-
reverse_order
Booltrigger in reverse order (binded last get called first)
-
expand_parameters
Boolparameters are passed not as one single parameter, but as many return {bool} true if the event passed was blocked by any binded callback
LEvent.triggerArray
-
array
-
event_name
-
parameters
-
reverse_order
-
expand_parameters
Triggers and event to every element in an array. If the event returns true, it must be intercepted
Parameters:
-
array
Arraycontains all instances to triggers the event
-
event_name
Stringstring defining the event name
-
parameters
that will be received by the binded function
-
reverse_order
Booltrigger in reverse order (binded last get called first)
-
expand_parameters
Boolparameters are passed not as one single parameter, but as many return {bool} false
LEvent.unbind
-
instance
-
event_name
-
callback
-
target_instance
Unbinds an event from an instance
Parameters:
-
instance
Objectwhere the event is binded
-
event_name
Stringstring defining the event name
-
callback
Functionfunction that was binded
-
target_instance
Object[Optional] target_instance that was binded
LEvent.unbindAll
-
instance
-
target_instance
Unbinds all events from an instance (or the ones that match certain target_instance)
Parameters:
-
instance
Objectwhere 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
Objectwhere the events are binded
-
event
Stringname of the event you want to remove all binds