0

Hi

I have an event listener attached to something which will fire a lot based on some user action that has occured on the page or some javscript change. Unfortunately it will be something like 5 or 6 fires in the space of 250ms and I am only interested in the last fire so I can carry out the resource intensive processing. I'd like to ignore all of the fires before that.

Any way this can be achieved keeping in mind we don't know how many times it will fire.

2
Contributors
3
Replies
14
Views
4 Years
Discussion Span
Last Post by paulkd
0

I would say no, because if you don't know how many times it will fire, you wont know if the current fire is the last.

0

could there not be a way to check with milliseconds elapsed since the last check, i.e. if it has taken more than 500ms since a fire has occured it means this 'burst' of fires has stopped?

I don't know..

0

Yes, this is a "rule" that you could implement. You would need to record the time of each fire (you can overwrite a single variable) and then apply a rule that if a timespan greater than n (500ms in your example) has elapsed between the last recorded fire then this would signify that it was the last fire and take appropriate action.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.