JooseX.Observable.Listener - An event listener in Observable pattern
var listener = instance.on('event', handler, scope, { single : true, delay : 100 })
// to remove it
instance.un(listener)
listener.remove()
// to cancel the buffered event:
listener.cancel()
Boolean single
When set to true, this listener will be activated only once and then automatically removed.
Number delay
After listener activation, the actual call to handler function will be delayed on this value (in ms).
Number buffer
After listener activation, the actual call to handler function will be delayed on this value (in ms). Additionally if during the waiting period the event will be emitted again, the call to handler will be re-scheduled on the same value.
This attribute is useful, when you are not interested in the "intermediate" events and only wants to listen the "final" ones. So, for example if some event continuously fires several times in a row, the listener will be called only for the last one.
Note - you can cancel the scheduled invocation of handler with the cancel method.
Number bufferMax
Only meaningful in combination with
buffer
. This attribute makes the listener to stop the re-scheduling afterbufferMax
milliseconds, and force the activation of listener.You can use this attribute when some events continuously fires (like
mousemove
) and you don't want to react on every event, but, on one event every Xms. The period of time X will bebuffer + bufferMax
. So if you need to react on one event everybuffer
ms, set this attribute to 0.
remove()
Remove this listener from its instance.
cancel()
Cancel buffered calls to the handler function (if any).
This extension is supported via github issues tracker: http://github.com/SamuraiJack/JooseX-Observable/issues
For general Joose questions you can also visit #joose on irc.freenode.org or mailing list at: http://groups.google.com/group/joose-js
Web page of this module: http://github.com/SamuraiJack/JooseX-Observable/
General documentation for Joose: http://joose.github.com/Joose/
All complex software has bugs lurking in it, and this module is no exception.
Please report any bugs through the web interface at http://github.com/SamuraiJack/JooseX-Observable/issues
Nickolay Platonov nplatonov@cpan.org
This software is Copyright (c) 2010 by Nickolay Platonov.
This is free software, licensed under:
The GNU Lesser General Public License, Version 3, June 2007