Skip to content

this works well only for small subset of effects for monads like rx observable #1

@awto

Description

@awto

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions