-
Notifications
You must be signed in to change notification settings - Fork 25
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
Root Registry / Backrefs with deep observation #517
Comments
you can use a plain mobx reaction with getSnapshot to do it (since snapshots create a new ref any time anything inside that snapshot mutates)
|
@xaviergonz I see, however this does not provide me the changes (and path) inside this (deeply) observed observable, right? How could I get "path" and "changes" like this below? deepObserve(target, (change, path) => {
console.dir(change)
}) |
Sorry, maybe nested |
Just for the record, I want to do something very similar proposed by @xaviergonz here: #436 (comment) However my current issue is that I can't really setup nested onPatches(collection, (collectionPatches, collectionInversePatches) => {
collectionPatches.forEach((collectionPatch) => {
if(/*it is an "add" Patch I'm interested in*/) {
// I'd like to setup a "deep observation"
const objectToAdd = ... // we can get it from collectionPatch (eg. via path)
onPatches(objectToAdd, ...)
// ^ gives this error:
// subtreeRoot must be a tree node (usually a model or a shallow / deep child part of a model 'data' object)
}
// ...
})}) I assume, instead nested Is there any important downside of doing that / any gotchas you are aware of (in context of using keystone that way) ? |
Root registry with observation: Root registry with deep observation: About refs/backrefs: These might not really be the scope of keystone and the use cases are really custom and complex so I close the issue, but if anyone has comment on these, I'd appreciate it. |
Rationale:
It would be really nice to get updated about all changes (also deep updates) of all instances of a given Model in a canonical way "at a central place".
As I understand from keystone docs and the implementation,
getRefsResolvingTo
gives you back a standard mobxObservableSet
, which does not seem to support deep observation (by default). It would be nice to get updated about the deep changes of thisObservableSet
. Is it a preferred/canonical way to do it in keystone? Is it preferred to use it with mobx-utils' deepObserve? I myself did not try it out yet, but have found this Open issue: deepObserve not working with ObservableSet. I also mindupdateAllRefsIfNeeded=true
case.Am I missing something?
The text was updated successfully, but these errors were encountered: