Code Monkey home page Code Monkey logo

Comments (8)

yelouafi avatar yelouafi commented on May 18, 2024

While I understand the code splitting requirement. I tend to not agree with starting sagas from inside containers elements. Perhaps, it'd be better to start the dynamic sagas in the same place we update the store. For example, if we load some dynamic module with new reducers and sagas I can imagine

function updateAppWithNewModule(module) {
  updateStoreWithNewReducer( module.reducer )
  runSaga(module.saga)
}

FYI, I've already pushed changes in the master branch which include runSaga support (along with monitoring support).

from redux-saga.

tappleby avatar tappleby commented on May 18, 2024

Yeah a component was probably a bad example (though I have been curious if proc could be used locally within a component to manage complex flows). I mainly wanted to show the cancelling of saga on unmount.

Starting the saga at module load time seems like the correct approach; I could see this working well with dynamic routes in react-router.

from redux-saga.

yelouafi avatar yelouafi commented on May 18, 2024

though I have been curious if proc could be used locally within a component to manage complex flows

technically yes. actually proc has a signature like (iterator, subscribe, dispatch) -> Promise. So you can hookup take and put to any external input/output (aka csp channels). But I wouldn't recommend using an internal function, as the signature may change in the future.

This is another item on my todo list. Initially, I imagined runSaga(iterator, {subscribe, dispatch}) which would work with Redux Stores out of the box. But the store doesn't actually provide the triggered action to its subscribers, and I read in a related Redux issue that this is intentional (reduxjs/redux#1057).

Another solution I m considering is keeping the generic runSaga(iterator, {subscribe, dispatch}) and exposing the utility function storeChannel so we'll end up with something like

runSaga( iterator, storeChannel(store) )

With the benefit of being able to connect the Saga to any external channel

from redux-saga.

tappleby avatar tappleby commented on May 18, 2024

I do like the idea of keeping it generic, would remove the need for things like emitterFromStore or store enhancers mentioned in #13.

Is there a common interface that other libraries seem to be using for channel like functionality? closest thing I can think of is Rx.Subject.

from redux-saga.

yelouafi avatar yelouafi commented on May 18, 2024

Is there a common interface that other libraries seem to be using for channel like functionality? closest thing I can think of is Rx.Subject

Node duplex streams seems to mimics channel's take/put, but uses 2 independent channels reads/writes. It doesn't also use promises for communication

from redux-saga.

yelouafi avatar yelouafi commented on May 18, 2024

FYI. the new v0.4.0 supports runSaga

from redux-saga.

tappleby avatar tappleby commented on May 18, 2024

πŸ‘

from redux-saga.

guoqing2015 avatar guoqing2015 commented on May 18, 2024

ηœ‹ηœ‹θΏ™δΈͺ: https://github.com/GuillaumeCisco/redux-sagas-injector

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.