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

Integration with redux-api? #26

Closed
rdiazv opened this issue Mar 20, 2017 · 3 comments
Closed

Integration with redux-api? #26

rdiazv opened this issue Mar 20, 2017 · 3 comments

Comments

@rdiazv
Copy link

rdiazv commented Mar 20, 2017

Hi, first of all, great library! :)
My app is using redux-api and right now the only thing that I can't figure out is how to avoid duplicated requests on the renderer and main.

I should be using createAliasedAction to make the actions fire on the main process only, but redux-api auto generates the action creators... any advice??

@ghost
Copy link

ghost commented Mar 20, 2017

Hi, first of all, great library! :)

Thanks 😄

My app is using redux-api and right now the only thing that I can't figure out is how to avoid duplicated requests on the renderer and main.

I'm not quite sure how redux-api works. I've used https://github.com/hardchor/timesheets in the past to demo integration with different libraries, e.g. hardchor/timesheets#211 .
As a bit of background, the forwardToMain and forwardToRenderer middleware should already take care of that for you. It adds meta data to each action that basically tells each side where it came from and whether it should be forwarded.

I should be using createAliasedAction to make the actions fire on the main process only, but redux-api auto generates the action creators... any advice??

So redux-api just creates actions on the fly? Is there any way to hook in to the action creators?
createAliasedAction

@rdiazv
Copy link
Author

rdiazv commented Mar 20, 2017

Thanks for your answer. There is no way to customize the actions creators 😞 ... I will try to solve my problem with a different pattern.

@rdiazv rdiazv closed this as completed Mar 20, 2017
@ghost
Copy link

ghost commented Mar 20, 2017

Things like redux-api (or redux-saga) look nice at first, but they also take a lot of flexibility away from you.
I had a look through their source code. One possible solution I could see is to register your own middleware (it's not too hard, take a look at https://github.com/hardchor/electron-redux/blob/master/src/middleware/forwardToRenderer.js) that intercepts any redux-api actions (they seem to be namespaced) and apply createAliasedAction before re-firing it.

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

1 participant