Skip to content
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

Redux dev tools one step behind. #287

Closed
tomitrescak opened this issue Aug 4, 2017 · 6 comments
Closed

Redux dev tools one step behind. #287

tomitrescak opened this issue Aug 4, 2017 · 6 comments

Comments

@tomitrescak
Copy link

Hi, thanks for all the amazing work! I have an issue with connecting Redux dev tools to mobx state tree. While the connection works like charm, it seem that the process is one step behind. Please check the GIF. When I switch my UI component from "signIn" view to "resend verification" it dev tools the view change is recorder as "verification -> sign in".

mobx-state-tree

This is how I initialise my store:

const state = accountStore.create();
global.__store = state;
connectReduxDevtools(require('remotedev'), state);
state.setView('signIn');
return <AccountsRoot state={state} />;
@tinchoz49
Copy link

tinchoz49 commented Aug 4, 2017

I had exactly the same issue today. The connection works great, mobx-state-stree works great (it's an amazing library) but I noticed the same one step behind problem.

@theorye
Copy link

theorye commented Aug 11, 2017

Are you guys using the remotedev that connects to the remotedev.io server or a local server?

@tinchoz49
Copy link

Yes, I'm using remotedev.io server. It's happening the same problem in the todomvc example.

I think the problem is that redux for example runs a @@INIT action at the begin and then the next actions can do a diff of the state correctly.

In our case, MST doesn't have an init action and I don't think that is necessary, maybe we can simulate it to fix this issue.

@mweststrate
Copy link
Member

mweststrate commented Aug 12, 2017 via email

@tinchoz49
Copy link

tinchoz49 commented Aug 12, 2017

Hi @mweststrate @mattiamanzati! I've been thinking that maybe there is an issue here:

export function connectReduxDevtools(remoteDevDep: any, model: any) {

When you execute an action, MST detect the action using the onAction, a middleware that it's executing before the action applys the changes on the store, so when you get a snapshot of the store (line 93) you are getting the old state again and redux-devtools can't diff correctly (prevState == newState)

Maybe we can add new middleware onAfterAction or I was thinking in change the original onAction to:

onAction(
    target: IStateTreeNode,
    beforeListener: (call: ISerializedActionCall) => void, 
    afterListener: (call: ISerializedActionCall) => void 
)

What do you think?

mweststrate added a commit that referenced this issue Aug 24, 2017
@mattiamanzati
Copy link
Contributor

Fixed in 0.10.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants