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

Actions contain both api and schema #127

Open
TheAznShumai opened this issue Jan 10, 2018 · 0 comments
Open

Actions contain both api and schema #127

TheAznShumai opened this issue Jan 10, 2018 · 0 comments
Labels

Comments

@TheAznShumai
Copy link
Contributor

TheAznShumai commented Jan 10, 2018

image

Action contain both api calls and schema definitions. Action in essence should only contain messages to publish telling the redux reducer(consumer) what logic it needs to arrange the data. We should move these calls out of this file and adopt a paradigm for how to handle api calls/data modeling in the front end.

In the pass I have had a lot of success dealing with apis using the following resources

https://github.com/agraboso/redux-api-middleware
https://github.com/paularmstrong/normalizr

Essentially you want to write a wrapping function that only requires you to specify minimal data to hit a api source. Then in the reducer, you would want to run normalizr to organize the said data. This would create a paradigm where in order to hit a data source, you would follow the round of calling the wrapper function and adding a call to a reducer generating function for the data store incorporating you normalized schema.

Here is a good old blog post describing how you can wrap an api actions using this middleware which allows you to intercept the data to do things like schema, isLoading patterns, error Formatting, etc...
http://randycoulman.com/blog/2016/04/19/using-redux-api-middleware-with-rails/

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

No branches or pull requests

1 participant