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:
-
instanceObjectwhere to attach the event
-
event_nameStringstring defining the event name
-
callbackFunctionfunction to call when the event is triggered
-
target_instanceObject[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:
-
constructorObject
LEvent.hasBind
-
instance -
event_name
Tells if there is any callback binded to this event
Parameters:
-
instanceObjectwhere the are the events binded
-
event_nameStringstring 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:
-
instanceObjectwhere there are the events binded
-
targetObjectinstance 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:
-
instanceObjectwhere the are the events binded
-
event_nameStringstring defining the event name
-
callbackFunctionthe callback
-
target_instanceObject[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:
-
instanceObjectthat triggers the event
-
event_nameStringstring defining the event name
-
parametersthat will be received by the binded function
-
reverse_orderBooltrigger in reverse order (binded last get called first)
-
expand_parametersBoolparameters 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:
-
arrayArraycontains all instances to triggers the event
-
event_nameStringstring defining the event name
-
parametersthat will be received by the binded function
-
reverse_orderBooltrigger in reverse order (binded last get called first)
-
expand_parametersBoolparameters 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:
-
instanceObjectwhere the event is binded
-
event_nameStringstring defining the event name
-
callbackFunctionfunction that was binded
-
target_instanceObject[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:
-
instanceObjectwhere the events are binded
-
target_instanceObject[Optional] target_instance of the events to remove
LEvent.unbindAll
-
instance -
event
Unbinds all callbacks associated to one specific event from this instance
Parameters:
-
instanceObjectwhere the events are binded
-
eventStringname of the event you want to remove all binds
