Closed samuelgoto closed 4 years ago
I'm not aware of official guidance one way or another but other APIs like Web Bluetooth also follow the pattern of keeping the state on the object at which the event is fired rather than passing it as part of the event.
Having the current state on the object also matches things like the Battery Status API.
Can we close this issue?
Right now, our API is such that you get the state out of the detector, and you listen for "change" events to observe changes.
We should probably drop the "state" property of IdleDetector and pass it on the event listener as a parameter, e.g.:
Not entirely consistent with the sensors API [1], but the "reading" in the sensors API doesn't seem like the best analogy either.
@reillyg, does that make sense? any other supporting precendence here?
[1] https://developer.mozilla.org/en-US/docs/Web/API/Accelerometer