-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add update hook for core primitives #578
Comments
|
@BANOnotIT |
released |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently we have only one public method to hook an update of atom or action call -
onUpdate
from reatom/hooks. There are few DX problems with that:onUpdate
have two overloads for atom and action with different behaviour (callback parameters), it could be not obvious especially for an action, coz "update" and "action call" is not connected semantically.onUpdate
call made the whole graph hot and could produce memory leaks in rare cases (dynamic fabric on top of a shared state + forgetting about unsubscribe)onUpdate(anAtom, console.log)
, BUT after this line deletion you should fix imports too - extra work for a temporal debug.onUpdate
is a super common feature and one of the common tools to build almost anything with Reatom, it is strange that this API stored in a different package.The proposal: add the same hook to all atoms and actions of the core package.
The overhead would be only around 0.1KB!
The text was updated successfully, but these errors were encountered: