Redux-saga: Difference between revisions
Jump to navigation
Jump to search
Created page with "= About = * Manages side-effects * Depends on ES6 and Yield * Consumes and emits actions * Works without redux" |
No edit summary |
||
Line 4: | Line 4: | ||
* Consumes and emits actions | * Consumes and emits actions | ||
* Works without redux | * Works without redux | ||
= Generator functions = | |||
The functions does not execute. It waits until .next() is called and progresses through the function breaking after each yield | |||
<syntaxhighlight lang="javascript"> | |||
var delayGenerator = function* () { | |||
let data1 = yield delay(1000,1); | |||
console.info("Step 1"); | |||
let data2 = yield delay(1000,2); | |||
console.info("Step 2"); | |||
let data3 = yield delay(1000,3); | |||
console.info("Step 3"); | |||
} | |||
var obj = delayGenerator() | |||
obj.next() | |||
// Console Step 1 | |||
obj.next() | |||
// Console Step 2 | |||
obj.next() | |||
// Console Step 3 | |||
</syntaxhighlight> |
Revision as of 05:12, 28 May 2020
About
- Manages side-effects
- Depends on ES6 and Yield
- Consumes and emits actions
- Works without redux
Generator functions
The functions does not execute. It waits until .next() is called and progresses through the function breaking after each yield
var delayGenerator = function* () {
let data1 = yield delay(1000,1);
console.info("Step 1");
let data2 = yield delay(1000,2);
console.info("Step 2");
let data3 = yield delay(1000,3);
console.info("Step 3");
}
var obj = delayGenerator()
obj.next()
// Console Step 1
obj.next()
// Console Step 2
obj.next()
// Console Step 3