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

Usage with "in-flight", non-serialisable actions. #2

Closed
eldh opened this issue Sep 5, 2015 · 2 comments
Closed

Usage with "in-flight", non-serialisable actions. #2

eldh opened this issue Sep 5, 2015 · 2 comments

Comments

@eldh
Copy link

eldh commented Sep 5, 2015

As discussed here, FSA compliant actions can be non-serialisable while they are waiting for a promise to resolve, causing errors when trying to use this lib (JSON.serialize() fails).

I have a small example todo app that uses redux-actions and redux-promises, and I would love to find a way to add redux-immutable-state-invariant to it.

Not sure how to go about doing that though, and I'm not sure my understanding of the problem is correct.

I would guess though that the "isFSA()" and "isSerializable()" methods discussed in the issue mentioned above could be used to filter out actions that should not be checked. But then again, I'm not sure this lib should necessarily know too much about FSA... Perhaps it could be as easy as checking if the payload is a Promise?

Or is it better to find a way to completely avoid non-serialisable actions?

Maybe @acdlite has some input?

@leoasis
Copy link
Owner

leoasis commented Sep 6, 2015

@eldh what's your particular use case? The original idea of this library is to work with plain actions that go directly to the reducer, that is, after all the middlewares have been executed. So you should place this middleware after all the other middlewares that transform your dispatched actions into the final ones that transform the state.

Is there a specific reason you would want this to work with the other intermediate actions?

Having said that, ideally I would love to have the same behavior to print stuff in the console as console.log, where objects and functions and everything gets printed correctly, instead of relying on JSON.stringify. If there's a better way to get an action pretty printed, I'm all for it.

@eldh
Copy link
Author

eldh commented Sep 8, 2015

Sorry, it was just me who didn't understand the importance of the order of middleware in this case. Placing it at the end works fine.

@eldh eldh closed this as completed Sep 8, 2015
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

2 participants