When using the area measuring tool, for each point you add (starting from the third point) the widget starts making areasAndLength requests to the geometry service to find the surface area of the current polygon. After receiving the surface from areasAndLength, the widget sends a "measure" event each time (except the last time where it sends you a "measure-end" event if you double-clicked instead of clicked).
The problem is that if for some reason the areasAndLength requests are pending and take a while to return, it doesn't stop you from adding points and even double-clicking to add the last point. Then when the areasAndLength requests finally return, instead of sending the "measure" events and one final "measure-end" event, the widget sends a bunch of "measure-end" events.
This is problematic because I have specific/different code in my "measure" and "measure-end" event handlers.
If all goes well it works fine, but intermittently if there's a lag with the geometry service then the wrong handler will be called multiple times, creating a bug in my application.
I can't figure out a way to work around this at the moment. I can't just ignore the extra "measure-end" events, I really need to call my regular "measure" event handler for each point, but the thing is when I receive the first "measure-end" event, I have no idea that more might follow because of this issue. Otherwise I would just redirect it to my "measure" handler instead.
I'm wondering if anyone else has this problem and how they deal with it.
Thanks