Open gruvw opened 8 months ago
The naming would more more "useOnListenableChange", like "useOnStreamChange" And it would take a single listenable, not a list of listenable.
Otherwise LGTM. Feel free to make a PR if you want to :)
Ok sure I will try and make a PR! Let me know if I mess up something doing so as it's only my second one :)
However why not a list of listenables ? It's more convenient isn't it ?
Folks wanting to listen to multiple listenables can use the hook multiple times or use Listenable.merge
It's rare that they'll want to listen to multiple listenables at once.
Is your feature request related to a problem? Please describe.
When using
Listenable
withuseEffect
it can be a bit cumbersome to always repeat the same boilerplate offaddListener
andremoveListener
again and again:keys.length
timesaddListener
key.addListener(...)
for each keyuseEffect
closureDescribe the solution you'd like
Add a
useListener
hook.Additional context
This would be very useful to bind values when some controller changes:
and even when it depends on multiple controllers like: