You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is a pretty typical and simple example, say, we need to update DB before some further actions, this is HTTP POST running using promises. Promises may be turned into observable, and JS has no its own side effects:
doMerge(function*() {
const m = yield fromPromise(updateDb())
const x = yield from([1,2])
return `${x} ${m}`
}).subscribe(function(res) {
console.log(res)
})
This updates DB 4 times!
More details in this gist.
And it is even theoretically not possible, arbitrary monad requires first class continuations, just coroutines are not enough.
There is in fact my tools (sorry for promoting it in this issue, but I suppose it may be interesting) may use same generators syntax for arbitrary monad.