React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.
MIT License
3.07k
stars
175
forks
source link
Trigger a callback when value listenable changes #326
Is your feature request related to a problem? Please describe.
Having a big and complicated screen, that is optimised using useValueNotifier instead of useState, often there is a need to do something when value notifier changes.
Using useValueListenable would trigger rebuild, which is unwanted due to rebuilds optimisation
Describe the solution you'd like
There is a way to add and remove listener to value notifier. This could be utilised to build a useValueListenableChanged hook, similar to useValueChanged hook that is present already.
Describe alternatives you've considereduseValueChanged hook works on a regular variable, not on valueListenable
Additional context
Here is what seemed to have worked. If there is no negative feedback I can make a PR:
Is your feature request related to a problem? Please describe. Having a big and complicated screen, that is optimised using
useValueNotifier
instead ofuseState
, often there is a need to do something when value notifier changes. UsinguseValueListenable
would trigger rebuild, which is unwanted due to rebuilds optimisationDescribe the solution you'd like There is a way to add and remove listener to value notifier. This could be utilised to build a
useValueListenableChanged
hook, similar touseValueChanged
hook that is present already.Describe alternatives you've considered
useValueChanged
hook works on a regular variable, not onvalueListenable
Additional context Here is what seemed to have worked. If there is no negative feedback I can make a PR: