[dojo-contributors] Generalized Frequency Checker class

LiuCougar liucougar at gmail.com
Mon Jun 26 02:10:41 EDT 2006

Hi all,
I noticed a comment in Editor2.js for a generalized Frequency Checker
class. Attached is the patch containing the class I implemented and
the patch to let Editor2 make use of it.

At the moment, the class is named dojo.timer, I am not happy with it
at all, I think a better name is needed. In addition, for simplicity,
I included this class in Editor2.js. I'd also like to hear, if you
guys like this class, then which package should this be placed?

Some more explanation about this class dojo.timer:
it can wrap a member function in an object to ensure that it does not
called so frequently.
How to use it:
you have an object and one of its member function expensiveFunction is
expensive to run, so you use dojo.timer to "protect" it like this:
object.timer = new dojo.timer();
object.timer.wrap(object, "expensiveFunction");

the frequency can be configured as well
(see the patch for a real use case)

Another possible use case for this class is to prevent the
placeDialog() in Dialog widget is called too frequently (when using
wheel in the mouse to scroll, lots of onScroll events are generated
quite quickly)

what do you think?

"People's characters are strengthened through struggle against
difficulties; they are weakened by comfort."
- Old Chinese adage
-------------- next part --------------
A non-text attachment was scrubbed...
Name: frequencychecker.patch
Type: application/octet-stream
Size: 2067 bytes
Desc: not available
Url : http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20060626/9670f22f/attachment.dll 

More information about the dojo-contributors mailing list