-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Listen to deep $state
changes like $inspect
but in prod mode?
#15078
Comments
$state
changes like $inspect
in dev mode?$state
changes like $inspect
but in prod mode?
If you want a quick-and-dirty solution, just |
Also there's this proposal #15069 that will allow you to specify a callback on the state itself (but you have to own the state) |
@elliott-with-the-longest-name-on-github nah, i'd rather add each key separately to the |
@paoloricciuti this looks great! by owning the state do you mean like the global exported |
I mean that you can't do this with a prop for example...it has to be declared state |
|
Great! thanks @brunnerh. Just one more thing, would this |
Yes, |
Also $state.snapshot uses structuredClone under the hood, which is MUCH less performant than JSON.stringify when you just want to read the values |
I'm gonna close this since it's already doable in some way or another...thanks for reporting |
Describe the problem
Is there a proper way to listen to any deeply nested change in the
$state
object? Here's a minimal reproduction linkWhen you make changes to
Name
input it fires theconsole.log()
but on changes toMethod
andURL
nothing happensIf you comment out the
$effect
logic and uncomment$inspect
one this works for all input changes and it would be ideal for me but it becomes a no-op in production build as stated in the docsCan i do this without needing to explicitly add each key to the
listenTo
array in the repro?Describe the proposed solution
$inspect
but for production?Importance
would make my life easier
The text was updated successfully, but these errors were encountered: