Replies: 3 comments 2 replies
-
MobX will only recurse into plain data structures; class instances won't be touched, so if your B tree has a prototype it will be safe. |
Beta Was this translation helpful? Give feedback.
2 replies
-
MobX doesn't allow makeing class instances observable from the 'outside'.
Introducing observability is the responsibility of the constructor, so
subclassing might help you here, but that depends a lot on the library.
…On Tue, Apr 27, 2021 at 3:13 PM David Piepgrass ***@***.***> wrote:
I don't know what "be safe" means, but the goal is correct behavior. So,
how do I get reactivity to work correctly? Also, BTree has a superset of
the Map and Set methods. Would it be possible to piggyback on whatever MobX
does for those types?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2922 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBFRVVZJHJJ4NYKP66LTK3BBRANCNFSM43T6OIGQ>
.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
… On Tue, Apr 27, 2021 at 3:24 PM David Piepgrass ***@***.***> wrote:
P.S. it's strange that I've been reading the documentation for hours and
never saw mention of a dichotomy between constructor-having and
constructor-lacking objects. Where do you document all these fine details?
Definitely not in the API reference <https://mobx.js.org/api.html>, which
doesn't even include parameter info.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2922 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBAX326OKUAF6KGM6GLTK3CLPANCNFSM43T6OIGQ>
.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
MobX supports the standard collection types Array, Map and Set. But what would happen if one tried to use a third-party data structure such as this B+ tree inside an observable object?
Internally, this data structure mutates itself in the usual way - setting its own properties, modifying internal arrays with methods like
push
andsplice
- but of course it is unaware of MobX and I wonder if this could cause any problems if it were used with, say,makeAutoObservable
.It is not documented whether
makeAutoObservable
recursively modifies subobjects, but I assume it does based on MobX code examples I've seen.Whether or not this data structure is compatible with MobX, I expect MobX to have significant overhead, e.g. it will create some kind of state information for every public and internal method inside the B+ tree, even though any given application doesn't use all of those functions, and it will have to keep track of changes to the tree in detail. So, is there a way to treat the whole thing as a "black box" — to inform MobX when a prop of type
BTree
is read or written, but not rewire all of the internals of the data structure?Beta Was this translation helpful? Give feedback.
All reactions