Replies: 3 comments 11 replies
-
I very much feel like Qwertie in this reply, as this problem really touches on my issue What is the proper way to observe changes in an ObservableMap? |
Beta Was this translation helpful? Give feedback.
-
Firstly computeds are not eager, they should not contain side effects - logging a value is a side effect. You can think about them like normal getters with cached result, which is invalidated when some dependency changes. You don't have to create any copies in
Sort of. The problem is the question. There is usually no point in observing state changes, unless you actually want to do something with the changed state. What you want to do is the crucial part here, because it defines what mobx will observe. Eg: autorun(() => {
log(object);
}) doesn't fire whenever |
Beta Was this translation helpful? Give feedback.
-
yes. But in rxjs I'd combine multiple streams here as well, so in terms of
RxJS the above would be an combineLatestAll of the filter stream. To
understand MobX, basically think of each and every object property as being
a separate stream, but with batching to avoid the diamond problem and skip
irrelevant intermediate states, and a combineLatestAll on every stream that
you actually read something from, rather than just naively all streams.
…On Wed, Apr 12, 2023 at 1:40 PM Ruan Heyns ***@***.***> wrote:
Yeah exactly. I come from rxjs, so observable streams are where my head is
at. Will the code above work?
—
Reply to this email directly, view it on GitHub
<#3659 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBFU2EUFI5O43SFJUZDXA2IBJANCNFSM6AAAAAAWCPIICQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
So I feel I understand MobX, or at least I did, until a while ago.
I have an Observable Map.
Right. And Filter type has a few props, most important being
Fairly simple right?
Now as for my computed value
activeFilters
. I understand that when I want activeFilters to update when I update the min and max, in the state, I would have to actually use/read the state, in the computed value. (Even if this isnt that intuitive)But this doesn't work:
However this does, since we're making a copy of the state, and this makes sense.
So does MobX really not see state being checked with
f.is_active && f.state
Beta Was this translation helpful? Give feedback.
All reactions