-
Notifications
You must be signed in to change notification settings - Fork 40
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
[RFC] Track nested changes with full path #5
base: master
Are you sure you want to change the base?
Conversation
Just checkedout master and merged with nested. Works with the "simple todo" example but only if the action is part of the Todo store. If it's extracted like so:
it doesn't work. |
@antitoxic, thanks for checking this out. That's because For example, Maybe @mweststrate has any clue? |
Few ideas:
If any of those are observables use them as parent path. |
I don't see how we can solve this from our part. There should be found a way on MobX part to pass (or better to detect) the target. Especially because it also makes |
Well if we can't find a target and one of the parameters passed is an observable, we can make a pretty good guess that the observable parameter is the target. Same with |
@antitoxic, I don't get it. We have only this information: {type: "action", name: "toggleStatus", target: undefined, arguments: Array[1], spyReportStart: true} I added you as a collaborator, you can make changes to this branch, so we can test it together. Honestly, as discussed with @mweststrate, I don't see any advantages of nested observables / classes, and don't use them. However, it would be great to get it work, so we can prove we can debug everything in MobX as in Redux. |
Ok. Consider this as just some brain teaser. I don't want to bother you with something you are not keen on. It's your project so it should serve you in the first place :)
Thank you. Could be useful.
Finding target from arguments if it's missing: function getTarget(change) {
var target = null;
if (change.target) {
return change.target;
}
for (let i = 0; i < change.arguments.length; i++) {
if (mobx.isObservable(change.arguments[i])) {
return change.arguments[i];
}
}
} |
If it was supposed to be only for my needs, I wouldn't opensourced it :)
That would do the trick indeed. I missed that we pass the observable as an argument. |
In relation to #6 and because you (@zalmoxisus) were asking, I think the work needed to finish all scenarios for this pull request is not worth the effort right now and even more I don't think it's possible unless @mweststrate provides solution to walk up observable hierarchy. The string splitting of debug name seems unreliable. |
As discussed in #2 and #3, we want to track nested changes without explicitly wrapping them in
remotedev()
. In order to help debugging, to cancel (skip) actions and to autogenerates tests, we also want to add the path to the action name like following:This PR is just a proof of concept, it works only for arrays added with
splice
. We need to handle other observable types and update types. There's a lot of work, so feedback is welcome. Maybe we could get some information directly from MobX?