Name

JooseX.Observable.Listener - An event listener in Observable pattern

SYNOPSIS

    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()

ATTRIBUTES

single

Boolean single

When set to true, this listener will be activated only once and then automatically removed.

delay

Number delay

After listener activation, the actual call to handler function will be delayed on this value (in ms).

buffer

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.

bufferMax

Number bufferMax

Only meaningful in combination with buffer. This attribute makes the listener to stop the re-scheduling after bufferMax 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 be buffer + bufferMax. So if you need to react on one event every buffer ms, set this attribute to 0.

METHODS

remove

remove()

Remove this listener from its instance.

cancel

cancel()

Cancel buffered calls to the handler function (if any).

GETTING HELP

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

SEE ALSO

Web page of this module: http://github.com/SamuraiJack/JooseX-Observable/

General documentation for Joose: http://joose.github.com/Joose/

BUGS

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

AUTHORS

Nickolay Platonov nplatonov@cpan.org

COPYRIGHT AND LICENSE

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