Comments (2)
the latest version includes a runSaga
function to start a saga outside of Redux. You can also connects the Saga to a custom input/output.
One idea is to use this function to connect a Saga to a React component, I mean for things that uses uniquely the local component state. For example provide a ReactComponentIO which routes component events as input to Sagas (to resolve take
effects) and connects the output of the Saga to component's setState (to resolve put
effects)
function* myComponentSaga(comp) {
while(true) {
yield take('CLICK')
// yield some stuff
yield put({clicked: true}) // same as setState({clicked: true})
}
}
class MyComponent extends React.Component {
componentDidMount() {
this.sagaIO = ReactComponentIO(this)
runSaga(mySaga(this), this.sagaIO) )
}
render() {
return (
...
<button onClick={this.sagaIO.fire({type: 'CLICK'})}
)
}
}
This is all quick and dirty, but can be refined further
from redux-saga.
I'll close this for the moment. Please feel free to add any comment. I can reopen it if necessary.
from redux-saga.
Related Issues (20)
- TypeError: Cannot assign to read only property 'cont' of object '#<Object>' HOT 1
- yield and takeLatest not working with jest HOT 8
- Waiting for an action with takeMaybe / take after END is dispatched for SSR HOT 7
- Is it possible to selectively cancel tasks in an actionChannel? Ie cancel the 3rd task out of 5 running ones. HOT 5
- Is it possible for a saga to "trace" the effect "chain"? HOT 4
- Delay inside of while loop may never fire with React Native 0.71.6 HOT 2
- UI freezes when chrome devtools is open HOT 4
- Redux 4.0 - Unable to access updated data using useSelector HOT 2
- could we add leading/trailing edge options for debounce? HOT 3
- Workflow has flaw
- Why not use the await and async instead of the generator and yield? HOT 1
- TS2345 error while putting thunk actions
- React native Redux Saga with Redux Tollkit
- Module '"redux-saga/effects"' has no exported member 'call'. HOT 4
- Is there a standard way to break while true loops with call effect when END is dispatched? HOT 1
- Can put type improvements be released downstream? HOT 2
- Sending very large files, tasks in parallel are using a lot of memory
- How to use package that use redux-saga as dependency when its in webpack externals? HOT 7
- Help me connect redux-saga with Nextjs 13.5 using app router HOT 2
- Update peer dependencies to include `redux@5` (currently beta) HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-saga.