That actually sounds like it works pretty well. Even though you are getting multiple triggers, you are still preventing an enormous volume of mousemove updates. (I am assuming the time until reactivation is relatively long).
The only thing that I would add is a filter on MoveMsg updates... if `active` is already set to False, ignore the MoveMsg update entirely. That way you guarantee you aren't triggering multiple calls to Reactivate. On Sun, Nov 20, 2016 at 1:24 AM, Matthieu Pizenberg < [email protected]> wrote: > I have been trying something that I think could be shared. > > Basically I tried to see if it was possible to throttle commands by > controlling the event attributes in the view that generate those commands. > Well, turns out, not really ^^. The idea was the following: > > * In the model, have an attribute `active : Boolean` initialized at True > (meaning that the event will trigger). > * In the `MoveMsg` case of update function, set `active` to False and > create a command that will reactivate it later in some time. > * In the `Reactivate` case of update, reset `active` to True. > * In the view, use `div [on "mousemove" ...] [...]` if active else `div [] > [...]` > > This almost work (so it doesn't ^^). Since mouse events can be triggered > more often than the rendering of the view, multiple mousemove events can be > triggered before the `[on "mousmove" ...]` is removed. > In practice the longer the functon in your mousemove update, the higher > are the chance that I got these multiple trigger before deactivation of the > listener. > > -- > You received this message because you are subscribed to the Google Groups > "Elm Discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
