How to put() within a callback?
See original GitHub issueThere have been a few instances where I’ve wanted to put
within a callback to realize that the action never gets reduced on. Is it possible to do the following with sagas?
function* hideNotification() {
let clearTimer = null;
const { SET_NOTIFICATION, CLEAR_NOTIFICATION } = NotificationActions.actionTypes;
while(true) {
const action = yield take([SET_NOTIFICATION, CLEAR_NOTIFICATION]);
if (clearTimer) {
clearTimeout(clearTimer);
clearTimer = null;
}
if (action.type === SET_NOTIFICATION) {
clearTimer = setTimeout(() => put(NotificationActions.clearNotification()), 300);
}
}
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:18
- Comments:36 (11 by maintainers)
Top Results From Across the Web
JavaScript Callback Functions – What are Callbacks in JS and ...
In JavaScript, the way to create a callback function is to pass it as a parameter to another function, and then to call...
Read more >How to access the correct this inside a callback
We explore the methods for accessing the correct this in a callback by explicitly forcing a context binding to point to our object...
Read more >How to access the correct `this` inside a callback?
Approach: First create an object and enter sample properties. Make sure you add a function for one key, in that function add a...
Read more >javascript - How to access the correct `this` inside a callback
1. Use the bind() function. function MyConstructor(data, transport) { this.data ...
Read more >Mastering 'this' in JavaScript: Callbacks and bind(), apply(), call()
Mastering 'this' in JavaScript: Callbacks and bind(), apply(), call(). Mar 2nd, 2018 10:23am by Michelle Gienow.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I still don’t get it. I’ve read several issues and other texts about this topic… Mostly they solve complex problems and not a simple thing like mine. Can someone point me to a tutorial or something else that shows me how to pass a simple “yield put” within a callback?
In my scenario i have to place a callback to receive the progress of a download-task and i want to put it into the redux-store with “yield put”.
All i want to do is something like this:
How to achieve that simple case? And why is it so difficult?
https://decembersoft.com/posts/file-upload-progress-with-redux-saga/