sentineljs icon indicating copy to clipboard operation
sentineljs copied to clipboard

Rename on(), off() functions to watch(), ignore()

Open danhardman opened this issue 8 years ago • 4 comments

I've only renamed the fields on the returned singleton for now to keep things simple, but I think on() and off() functions don't make sense without an attributed action. Typically you'd get on('click',...) for example.

This just makes things clear that you're setting up a watcher/listener on the CSS selector.

danhardman avatar Sep 18 '17 10:09 danhardman

Thanks! Let me think about it some more. I used on/off for symmetry with jQuery but I like watch(). What do you think of disconnect() instead of ignore()?

amorey avatar Sep 18 '17 14:09 amorey

Yeah it kinda clicked that ignore() probably isn't the best name if its intended to only work when a watcher is already setup on that selector. disconnect() or stop() I think would work well.

danhardman avatar Sep 18 '17 15:09 danhardman

How about observe() and disconnect()? MutationObserver has these methods.

distums avatar Sep 19 '17 06:09 distums

What about subscribe() and unsubscribe() like with es6 observables [1]

[1]: https://github.com/tc39/proposal-observable#example-observing-keyboard-events

leipert avatar Sep 20 '17 14:09 leipert