-
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
Globally tracking actions #2
Comments
@antitoxic, thanks a lot for the feedback and the suggestion! I'm going to cut Though it's a good idea to just use
After we get zalmoxisus/redux-devtools-extension@6e23813 published, you will be able to open separate windows for every instance like so: |
Actions are just functions in mobx, right? Would you keep reference to the function? I'm interested in how it will be done. I am working locally on a version that supports nested observables by relying on the following info:
Sample working code: export default function spy(store, config) {
init(store, config);
if (isSpyEnabled) return;
isSpyEnabled = true;
reaction(() => serialize(store), function () {}); // trigger tracking of all observables
mobx.spy((change) => {
if (!change.spyReportStart) return;
if (change.type === 'reaction') {
try {
var objName = getName(change.object.observing[0].sourceObject); // refer to the serialization reaction above
send(objName)
}
catch (e) {
return; // TODO: show other reactions
}
}
if (change.type === 'action') {
const action = createAction(change.name);
if (change.arguments && change.arguments.length) action.arguments = change.arguments;
schedule(action);
} else if (change.type && mobx.isObservable(change.object)) {
schedule(createAction(change.type, change));
}
});
} I was going to give you a link to a fork but I saw the repo was updated since I started editing and I'm not in a mood for conflict resolution :) What do you think about the code above? |
Yes, I'd like to send all the functions name to the monitor and just select which function want to call from UI. But for now you just indicate the function name as
Looks interesting, but still wondering if mixing stores in one instance would be reasonable. We wouldn't be able even to show diffs, which is by default when opening the monitor. Autogenerating instances wouldn't work as well. Will try your fork. Thanks for working on this!
I will change only |
Actually diffs are possible. I got them working. I don't understand what you mean by "Autogenerating instances wouldn't work as well." |
I thought we'll have separate states for every object, so it wouldn't make sense to have a diff between If this "hack" with serialization is viable and works for classes as well, it will be indeed a better solution than calling Would you like to send a PR? |
Working on it. 👍 |
Hi @zalmoxisus . @mweststrate mentioned the project.
I'm a fan :)
Just a few questions regarding handling mobx. In Mobx, stores are usually nested. I see the todo example in which
remotedev()
is called on each nested store instance. Do you think this is optimal?In my opinion, a useful option for
remotedev
, one that covers most of the cases, will be to enable spying on all mobx observables or all nested ones at least without the need to wrap the nested stores.Why? - because right now, I need to switch from a parent store to a child store to see a change which affects both. Correct me if I'm wrong here.
The text was updated successfully, but these errors were encountered: