kubetail-org / sentineljs

Detect new DOM nodes using CSS selectors (650 bytes)
MIT License
1.13k stars 51 forks source link

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

Open danhardman opened 6 years ago

danhardman commented 6 years ago

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.

amorey commented 6 years ago

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()?

danhardman commented 6 years ago

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.

distums commented 6 years ago

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

leipert commented 6 years ago

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

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