I am fairly new to Meteor and have been messing around a lot lately integrating Meteor with Redux - so far it has been pretty smooth. However, I am a little confused on the best approach to handle consuming APIs with Meteor and Redux.
In a lot of the Redux tutorials I have been going thru the application will setup a middleware that will be used before any actions go to the reducers. One of the common middlewares that is applied is redux-promise. With redux-promise the client can use some kind of promised based http request library and makes async requests and have the app optimistically update.
However, when going thru Meteor tutorials, the standard seems to be that you make http requests using Meteor methods - the client will invoke some kind of meteor method which will kick off an http request using the the HTTP package.
When using Redux and Meteor combined, I am not really sure what the best approach is to make http requests. What are the advantages to using one over the other? Should I even use redux-promise middleware in a Meteor app? Any help would be greatly appreciated!
I am not very experienced in Meteor-Redux but I started to use Meteor methods in Redux actions (and only there) with help of redux-thunk You can see it in my boilerplate: https://github.com/juliancwirko/scotty Also I don’t use pub/sub if I don’t have to. I try to use only Meteor methods calls and redux stuff. I think it is enought in most cases unless you want something like chats or games.
Maybe I’m not fully understanding your need here but Meteor, Redux and API consumption is delt with beautifully with Apollo. I’m working on a product with Redux taking care of state, Meteor dealing with login/user and consuming mongo/postgre data on server all made easy with graphql. Seems simple to add REST or other API and deal with on server (plus using npm packages very easy there too).
The great thing is Apollo client ties it all in to Redux for you. So once you have the server side setup the client side is very simple and all data is neatly presented on the state for you.
Sure, give me a few days to repo it for you. It’s a work in progress with some branding I’ll remove.
I’m also conscious that sashko and team are busy working on it (apollo) so I’m expecting some breaking changes in the near future. Personally I’m willing to go with that just because I’m having such fun working with it.
Also very little of it is my own work, I just tied two examples together:
sashko’s starter kit and abhiaiyer91 shopping cart for the postgre stuff.