Event.Listener Class
Extends the Event-instance by adding the object Listener
to it.
The returned object should be merged into any Class-instance or object you want to
extend with the listener-methods, so the appropriate methods can be invoked on the instance.
Copyright (c) 2014 ITSA - https://github.com/itsa New BSD License - http://choosealicense.com/licenses/bsd-3-clause/
Should be called using the provided extend
-method like this:
Item Index
Methods
- after
- after
- after
- before
- before
- before
- detach
- detach
- detach
- detachAll
- detachAll
- detachAll
- onceAfter
- onceAfter
- onceAfter
- onceBefore
- onceBefore
- onceBefore
- selfAfter
- selfAfter
- selfAfter
- selfBefore
- selfBefore
- selfBefore
- selfOnceAfter
- selfOnceAfter
- selfOnceAfter
- selfOnceBefore
- selfOnceBefore
- selfOnceBefore
Methods
after
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed after
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
after
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed after
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
after
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed after
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
before
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed before
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
before
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed before
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
before
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed before
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
detach
-
customEvent
Detaches (unsubscribes) the listener from the specified customEvent, on behalf of the object who calls this method.
Parameters:
-
customEvent
Stringconform the syntax:
emitterName:eventName
, wildcard*
may be used for bothemitterName
as well as onlyeventName
, in which case 'UI' will become the emitterName.
detach
-
customEvent
Detaches (unsubscribes) the listener from the specified customEvent, on behalf of the object who calls this method.
Parameters:
-
customEvent
Stringconform the syntax:
emitterName:eventName
, wildcard*
may be used for bothemitterName
as well as onlyeventName
, in which case 'UI' will become the emitterName.
detach
-
customEvent
Detaches (unsubscribes) the listener from the specified customEvent, on behalf of the object who calls this method.
Parameters:
-
customEvent
Stringconform the syntax:
emitterName:eventName
, wildcard*
may be used for bothemitterName
as well as onlyeventName
, in which case 'UI' will become the emitterName.
detachAll
()
Detaches (unsubscribes) the listener from all customevents, on behalf of the object who calls this method.
detachAll
()
Detaches (unsubscribes) the listener from all customevents, on behalf of the object who calls this method.
detachAll
()
Detaches (unsubscribes) the listener from all customevents, on behalf of the object who calls this method.
onceAfter
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed after
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
onceAfter
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed after
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
onceAfter
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed after
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
onceBefore
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed before
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
onceBefore
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed before
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
onceBefore
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed before
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfAfter
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed after
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfAfter
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed after
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfAfter
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed after
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfBefore
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed before
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfBefore
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed before
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfBefore
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed before
the defaultFn.
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfOnceAfter
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed after
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfOnceAfter
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed after
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfOnceAfter
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed after
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of after-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfOnceBefore
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed before
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfOnceBefore
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed before
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber
selfOnceBefore
-
customEvent
-
callback
-
[filter]
-
[prepend=false]
Is automaticly available for Classes. Subscribes to a customEvent on behalf of the class-instance and will only be executed when the emitter is the instance itself.
The callback will be executed before
the defaultFn.
The subscriber will be automaticly removed once the callback executed the first time.
No need to detach()
(unless you want to undescribe before the first event)
Parameters:
-
customEvent
String | Arraythe custom-event (or Array of events) to subscribe to. CustomEvents should have the syntax:
emitterName:eventName
. Wildcard*
may be used for bothemitterName
as well aseventName
. IfemitterName
is not defined,UI
is assumed. -
callback
Functionsubscriber:will be invoked when the event occurs. An
eventobject
will be passed as its only argument. -
[filter]
String | Function optionalto filter the event. Use a String if you want to filter DOM-events by a
selector
Use a function if you want to filter by any other means. If the function returns a trully value, the subscriber gets invoked. The function gets theeventobject
as its only argument and the context is the subscriber. -
[prepend=false]
Boolean optionalwhether the subscriber should be the first in the list of before-subscribers.
Returns:
handler with a detach()
-method which can be used to detach the subscriber