Skip to content

fix logger order #102

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

Merged
merged 5 commits into from
Jan 9, 2016
Merged

fix logger order #102

merged 5 commits into from
Jan 9, 2016

Conversation

jetzhliu
Copy link

When redux dispatch an action, after calling the reducer, the listeners
will be called. If the listener dispatch a new action, redux allow it,
but the order of the log will in reverse.
this PR fix the order in that case.

When redux dispatch an action, after calling the reducer, the listeners
will be called. If the listener dispatch a new action, redux allow it,
but the order of the log will in reverse.
this PR fix the order in that case.
@imevro
Copy link
Collaborator

imevro commented Dec 14, 2015

Can you make a demo, please?

@jetzhliu
Copy link
Author

OK, but it may take some time because of my bad network~~
You can also add a listener to the store, and dispatch a new action in some case, then the later action will log first. It may be a bad pattern, but some 3rd lib do that...

@imevro
Copy link
Collaborator

imevro commented Dec 14, 2015

I'll try tomorrow.

@hon2a
Copy link

hon2a commented Dec 14, 2015

I can confirm the issue is real. Listeners subscribed to redux store are executed synchronously, so running next(action) inside the logger actually executes all subscribed listeners. If any of them dispatch any other action in reaction to the updated state, this other action is dispatched on top of the current stack and it is therefore logged before the original action.

@bitfrost
Copy link

bitfrost commented Jan 4, 2016

We are also seeing this, @theaqua would you like a demo still? If so I can put one together.

@imevro
Copy link
Collaborator

imevro commented Jan 5, 2016

@bitfrost yes please. I don't have enough time :(

@bitfrost
Copy link

bitfrost commented Jan 5, 2016

Here you go:
https://github.com/bitfrost/logging-in-wrong-order

https://github.com/bitfrost/logging-in-wrong-order/blob/master/index.es6

open index.html and view the logger output and compile it with console.log output from the 1 reducer.

@imevro
Copy link
Collaborator

imevro commented Jan 9, 2016

Thanks, @bitfrost!

Hey, @jetzhliu, can you fix merge conflict, please? I'll merge ASAP.

@jetzhliu
Copy link
Author

jetzhliu commented Jan 9, 2016

thank you very mush @bitfrost & @theaqua . I will merge conflict now.

@jetzhliu
Copy link
Author

jetzhliu commented Jan 9, 2016

I has merged conflict.
but I has one question: is it necessary to print preview state?

@imevro
Copy link
Collaborator

imevro commented Jan 9, 2016

@jetzhliu of course :)

Thanks!

imevro pushed a commit that referenced this pull request Jan 9, 2016
@imevro imevro merged commit 3f7ca51 into LogRocket:master Jan 9, 2016
@imevro
Copy link
Collaborator

imevro commented Jan 22, 2016

Released in 2.4.0.

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

Successfully merging this pull request may close these issues.

4 participants