Q.Event Class
platform/plugins/Q/web/js/Q.js:1979
Wraps a callable in a Q.Event object
Constructor
Q.Event
-
callable
-
[key=null]
-
[prepend=false]
Defined in
platform/plugins/Q/web/js/Q.js:1979
Parameters:
-
callable
CallableOptional. If not provided, the chain of handlers will start out empty. Any kind of callable which Q.handle can invoke
-
[key=null]
String optionalOptional key under which to add this, so you can remove it later if needed
-
[prepend=false]
Boolean optionalIf true, then prepends the callable to the chain of handlers
Item Index
Methods
add
-
handler
-
Optional
-
prepend
Defined in
platform/plugins/Q/web/js/Q.js:2095
Like the "set" method, adds a handler to an event, or overwrites an existing one. But in addition, immediately handles the handler if the event has already occurred at least once, or is currently occuring, passing it the same subject and arguments as were passed to the event the last time it occurred.
Parameters:
-
handler
MixedAny kind of callable which Q.handle can invoke
-
Optional
String | Boolean | Q.Toolkey to associate with the handler. Used to replace handlers previously added under the same key. Also used for removing handlers with .remove(key). If the key is not provided, a unique one is computed. Pass a Q.Tool object here to associate the handler to the tool, and it will be automatically removed when the tool is removed.
-
prepend
BooleanIf true, then prepends the handler to the chain
Returns:
The key under which the handler was set, or null if handler is empty
addOnce
-
handler
-
Optional
-
prepend
Defined in
platform/plugins/Q/web/js/Q.js:2143
Like "add" method, but removes the handler right after it has executed.
Parameters:
-
handler
MixedAny kind of callable which Q.handle can invoke
-
Optional
String | Boolean | Q.Toolkey to associate with the handler. Used to replace handlers previously added under the same key. If the key is not provided, a unique one is computed. Pass a Q.Tool object here to associate the handler to the tool, and it will be automatically removed when the tool is removed.
-
prepend
BooleanIf true, then prepends the handler to the chain
Returns:
The key under which the handler was set
and
-
anotherEvent
-
[key]
-
[anotherKey]
Defined in
platform/plugins/Q/web/js/Q.js:2272
Return a new Q.Event that occurs whenever either this or anotherEvent occurs as long as both have occurred.
Parameters:
Returns:
A new Q.Event object
copy
()
Q.Event
Defined in
platform/plugins/Q/web/js/Q.js:2240
Make a copy of this event, with all the keys and handlers
Returns:
debounce
-
milliseconds
-
[immediate=false]
-
[key]
Defined in
platform/plugins/Q/web/js/Q.js:2352
Return a new Q.Event object that waits until after this event's handle() stops being called for a given number of milliseconds, before processing the last call. If the immediate param is true, the wrapper lets the function be called without waiting if it hasn't been called for the given number of milliseconds.
Parameters:
-
milliseconds
NumberThe number of milliseconds
-
[immediate=false]
Boolean optionalif true, the wrapper lets the function be called without waiting if it hasn't been called for the given number of milliseconds.
-
[key]
String | Boolean | Q.Tool optionalOptional key to pass to event.add (see docs for that method).
Returns:
A new Q.Event object
factory
-
[collection]
-
[defaults]
-
[callback]
-
[removeOnEmpty=false]
Defined in
platform/plugins/Q/web/js/Q.js:2455
Make an event factory
Parameters:
-
[collection]
Object optionalThe object that will store all the events. Pass null here to auto-create one.
-
[defaults]
Array optionalYou can pass an array of defaults for the fields in the returned function The last element of this array can be a function that further processes the arguments, returning an array of the resulting arguments
-
[callback]
Function optionalAn optional callback that gets called when a new event is created. The "this" object is the Q.Event, and the parameters are the processed parameters passed to the returned factory function. The callback should return the event to be added to the collection (could just return this).
-
[removeOnEmpty=false]
Function optionalPass true here to remove events from the factory after their last handler is removed. They might be created again by the factory.
Returns:
Returns a function that can take one or more index fields and return a Q.Event that was either already stored under those index fields or newly created.
filter
-
test
-
[key]
Defined in
platform/plugins/Q/web/js/Q.js:2400
Return a new Q.Event object that will call handle() when this event's handle() is called, but only if the test function returns true
Parameters:
Returns:
A new Q.Event object
from
-
key
-
source
-
eventName
Defined in
platform/plugins/Q/web/js/Q.js:2033
Returns a Q.Event that will fire given an DOM object and an event name
Returns:
handle
()
Mixed
Defined in
platform/plugins/Q/web/js/Q.js:2003
Shorthand closure for emitting events Pass any arguments to the event here. You can pass this closure anywhere a callback function is expected.
Returns:
map
-
transform
-
[key]
Defined in
platform/plugins/Q/web/js/Q.js:2417
Return a new Q.Event object that will call handle() when this event's handle() is called, but with the arguments returned by the transform function
Parameters:
Returns:
A new Q.Event object
or
-
anotherEvent
-
[key]
-
[anotherKey]
Defined in
platform/plugins/Q/web/js/Q.js:2254
Returns a new Q.Event that occurs whenever either this or anotherEvent occurs
Parameters:
Returns:
queue
-
milliseconds
-
[key]
Defined in
platform/plugins/Q/web/js/Q.js:2386
Return a new Q.Event object that will queue calls to this event's handle() method, to occur once every given milliseconds
Parameters:
Returns:
A new Q.Event object
remove
-
key
Defined in
platform/plugins/Q/web/js/Q.js:2166
Removes an event handler
Parameters:
-
key
StringThe key of the handler to remove. Pass a Q.Tool object here to remove the handler, if any, associated with this tool.
removeAllHandlers
-
key
Defined in
platform/plugins/Q/web/js/Q.js:2209
Removes all handlers for this event
Parameters:
-
key
StringThe key of the handler to remove. Pass a Q.Tool object here to remove the handler, if any, associated with this tool.
set
-
handler
-
key
-
prepend
Defined in
platform/plugins/Q/web/js/Q.js:2052
Adds a handler to an event, or overwrites an existing one
Parameters:
-
handler
MixedAny kind of callable which Q.handle can invoke
-
key
String | Boolean | Q.ToolOptional key to associate with the handler. Used to replace handlers previously added under the same key. Also used for removing handlers with .remove(key). If the key is not provided, a unique one is computed. Pass true here to associate the handler to the current page, and it will be automatically removed when the current page is removed. Pass a Q.Tool object here to associate the handler to the tool, and it will be automatically removed when the tool is removed.
-
prepend
BooleanIf true, then prepends the handler to the chain
Returns:
The key under which the handler was set, or null if handler is empty
setOnce
-
handler
-
Optional
-
prepend
Defined in
platform/plugins/Q/web/js/Q.js:2120
Like "set" method, but removes the handler right after it has executed.
Parameters:
-
handler
MixedAny kind of callable which Q.handle can invoke
-
Optional
String | Boolean | Q.Toolkey to associate with the handler. Used to replace handlers previously added under the same key. If the key is not provided, a unique one is computed. Pass a Q.Tool object here to associate the handler to the tool, and it will be automatically removed when the tool is removed.
-
prepend
BooleanIf true, then prepends the handler to the chain
Returns:
The key under which the handler was set
stop
-
removeAllHandlers
Defined in
platform/plugins/Q/web/js/Q.js:2224
Indicates that the event won't be firing anymore
Parameters:
-
removeAllHandlers
BooleanIf true, then also removes all the handlers added to this event
then
-
[key]
Defined in
platform/plugins/Q/web/js/Q.js:2323
Return a new Q.Event object that waits until this event is stopped, then processes all the pending calls to .handle(), continuing normally after that.
Parameters:
Returns:
A new Q.Event object
throttle
-
milliseconds
-
delayedFinal
-
[key]
Defined in
platform/plugins/Q/web/js/Q.js:2370
Return a new Q.Event object that will call handle() when this event's handle() is called, but only at most every given milliseconds.
Parameters:
-
milliseconds
NumberThe number of milliseconds
-
delayedFinal
BooleanWhether the wrapper should execute the latest function call after throttle opens again, useful for e.g. following a mouse pointer that stopped.
-
[key]
String | Boolean | Q.Tool optionalOptional key to pass to event.add (see docs for that method).
Returns:
A new Q.Event object
until
-
anotherEvent
-
[key]
-
[anotherKey]
Defined in
platform/plugins/Q/web/js/Q.js:2301
Return a new Q.Event object that is handled whenever this event is handled, until anotherEvent occurs, in which case this event occurs one final time.
Parameters:
Returns:
A new Q.Event object