Skip to content

Mention that redux actions should be serializable #22

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

Closed
mironov opened this issue Aug 14, 2016 · 6 comments
Closed

Mention that redux actions should be serializable #22

mironov opened this issue Aug 14, 2016 · 6 comments

Comments

@mironov
Copy link

mironov commented Aug 14, 2016

Please add that to the Limitations section of the README.

For example redux-promise-middleware and redux-api-middleware v1 will not work because actions they produce are not serializable. redux-api-middleware v2 beta has String key instead of Symbol making it compatible with react-chrome-redux.

@viskin
Copy link

viskin commented Aug 14, 2016

Sorry that I intervene, but I don't think that "actions should be serializable" is limitation of react-chrome-redux.
As mentioned in this discussion, actions in redux should be plain objects. So creating not serializable actions is limitation of libraries that do that.
Maybe it really worth noting the fact of serializablility of actions in "reminder" section. Again, in my option, it's not limitation but conformance to redux architecture.

@mironov
Copy link
Author

mironov commented Aug 14, 2016

@viskin It is not a limitation of react-chrome-redux but of Chrome Extension Messaging API:

A message can contain any valid JSON object (null, boolean, number, string, array, or object).

The Redux app might work without a problem on the web or mobile (with react-native), but when you start porting it to the Chrome ecosystem you will encounter unexpected behavior. Moreover, there are no errors; actions just come to the background page without "non-serializable" fields.

redux-thunk async actions also can't be serialized, so the aliases hack exists. Probably we can re-use that trick for other middlewares, but we should at least highlight that in README.

@tshaddix
Copy link
Owner

tshaddix commented Aug 14, 2016

@mironov Have you looked into dispatchResponder? This was included to allow a "conversion" to a serializable object that the UI Components understand. The bottom example is an example with redux-promise-middleware. Please let us know if this helps (or not)!

@tshaddix
Copy link
Owner

Also, I'm happy to work with someone on the README sections. Right now it exists as a collection of wiki links.

@mironov
Copy link
Author

mironov commented Aug 14, 2016

@tshaddix Oh wow! Sorry, I overlooked this example somehow.

I think the easiest thing to do is to change headers to "Usage with redux-thunk" and "Usage with a promise middleware" on the Advanced Usage page.

Feel free to close the issue since the workaround is already documented.

@tshaddix
Copy link
Owner

@mironov, great to hear!

I agree we should probably breakout the Readme sections into something a little more recognizable. I would like to keep the documentation package-agnostic. Ideas?

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

No branches or pull requests

3 participants