You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the problem is, the {urlState.value} is not reflecting the counter variable. but, when i change the {urlState.value} to {url.value}, the value is changed each update
Intended outcome:
the {urlState.value} will reflect the counter variable
Actual outcome:
the {urlState.value} is not reflecting the counter variable. even with as simple as this was not working either
functiontest(){consturl=observable({value: 0,update: action((value: number)=>{url.value=value;consturlParam=newURLSearchParams(window.location.search);urlParam.set('count',String(value));// Use the argument value instead of url.valuewindow.history.pushState(null,'',`?${urlParam.toString()}`);}),watch: (callback: (value: number)=>void)=>{autorun(()=>callback(url.value))}})returnurl}consturlState=test()
How to reproduce the issue:
use the following function
functiontest(){consturl=observable({value: 0,update: action((value: number)=>{url.value=value;consturlParam=newURLSearchParams(window.location.search);urlParam.set('count',String(value));// Use the argument value instead of url.valuewindow.history.pushState(null,'',`?${urlParam.toString()}`);}),watch: (callback: (value: number)=>void)=>{autorun(()=>callback(url.value))}})returnurl}consturlState=test()
Versions
6.12.10
The text was updated successfully, but these errors were encountered:
You need to mark your component as an observer somehow. Do you use this package https://github.com/xelaok/svelte-mobx? I believe it’s better to address it there, since the Mobx organization doesn’t maintain any Svelte integration.
How to mark my component as observer? And no, i did not use svelte-mobx. I only use the vanilla/core mobx
I just confused that if my observable is wrapped inside a function and then return it, the reactive suddenly doesn't work. Of course i can use watch to watch if the value is changing. But the fact that the behavior is different if it's wrapped or not, feels wrong to me
If you observe any kind of reactivity in your templates, it's not provided by observable. You can probably remove the observable call and it will work the same way. Without any bindings, Svelte is completely unware of mobx's observables.
Don't use Mobx with Svelte, it doesn't make sense. Svelte solves the same problem by different means.
I want to make an indirection of url query state using mobx in svelte. i try to make it like this
and call it with this
i have a reactive counter on the html, and then
the problem is, the
{urlState.value}
is not reflecting the counter variable. but, when i change the{urlState.value}
to{url.value}
, the value is changed each updateIntended outcome:
the
{urlState.value}
will reflect the counter variableActual outcome:
the
{urlState.value}
is not reflecting the counter variable. even with as simple as this was not working eitherHow to reproduce the issue:
use the following function
Versions
6.12.10
The text was updated successfully, but these errors were encountered: