Created
August 12, 2019 11:45
-
-
Save ealipio/1b3f9acfea229ff2c600605cb8fb9f76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function request(url) { | |
makeAjaxCall( url, (response) => it.next( response)) | |
} | |
function main() { | |
const result = yield request('http://some.com/1') | |
const data = JSON.parse( result ); | |
const result2 = yield request('http://some.com/2' + data.id); | |
const response = JSON.parse( result2 ); | |
console.log(`The value you asked for is: ${response.value}`) | |
} | |
function* foo(){ | |
let x = yield "please give me a value for x" | |
let y = yield "please give me a value for y" | |
let z = yield "please give me a value for z" | |
return (x+ y +z) | |
} | |
const it = main(); | |
it.next() // get it all started | |
//============ another example: =============== | |
const myFoo = foo(); | |
myFoo.next(1); | |
myFoo.next(2); | |
myFoo.next(3); |
Author
ealipio
commented
Aug 12, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment