Fire action when user changed input but not when changed remotely


#1

I have a range input. Value of this input can be set by an incoming event (websockets) and by user interaction. When user changes this value I want to fire an action, but I don’t want it when value is changed remotely. I workaround it this way: https://github.com/cowbell/mopster/blob/ef9181c5a0eb0cd46a6c34c61798cb12edefeba2/app/components/volume-control.js#L16-L26

Do you know of any clear way of achieving that?


#2

Checking old/new values is a good solution

How about if the component only updates the range value after the “onmouseup” event has fired on the element, that should mean the socket can update the value but not trigger any events.


#3

I was afraid that it won’t work on mobile, but actually tapping on mobile fires “mouseup” event so it works fine (at least on latest chrome). Thanks.

I think it’s a common scenario to control input from few sources (by user interaction and remotely), so I thought it’s already solved in some nice manner.