Giter Site home page Giter Site logo

Comments (5)

yelouafi avatar yelouafi commented on May 3, 2024

Is this against what sagas are about? I've just interpreted them as middleware with much more advanced capabilities.

Against no I dont think. But sagas can do more than that. See

http://stackoverflow.com/questions/34930735/pros-cons-of-using-redux-saga-with-es6-generators-vs-redux-thunk-with-es7-async

Is there any equivalent to next from middleware in sagas? If you noticed I do a put in my apiCall, but it has an undesired behavior as it also sends that action to the reducers. I want to be able to do a put that only my sagas can receive basically.

As long as the action types arent of any meaning to the reducer. It will ignore them. But you can if you want create a filter middleware that intercept all saga actions and put it after the redux-saga middleware in the middleware chain

from redux-saga.

braco avatar braco commented on May 3, 2024

@yelouafi: what do you think of what @AriaFallah wrote, as a pattern? I too am put off by the repetitive boilerplate.

@AriaFallah: do you have more complete code anywhere public? Would be interested in seeing how that developed.

from redux-saga.

AriaFallah avatar AriaFallah commented on May 3, 2024

@braco not really sorry. I haven't worked on that project where I was using redux-saga in a while.

from redux-saga.

ryankask avatar ryankask commented on May 3, 2024

I found this issue after looking for solutions to reduce the amount boilerplate. For example, an API call like login "needs" three LOGIN_* actions, a login action creator, a login saga, and a login API utility function.

I haven't spent much time abstracting this although I did write an API request saga factory that looks something like the code posted above.

I'm eager to see what other users are doing.

from redux-saga.

jiayihu avatar jiayihu commented on May 3, 2024

I had the same issue, so I just created a small gist with my own implementation of an action creator factory: https://gist.github.com/jiayihu/811f2dc704d6ce6308d679a987348b20

Can be used as following:

export const addInvoice = createAction('ADD_INVOICE', {
  request: (invoice) => ({ invoice }),
  success: (invoice, result) => ({ invoice, result }),
});

from redux-saga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.