z icon indicating copy to clipboard operation
z copied to clipboard

async/await example

Open tkgalk opened this issue 7 years ago • 1 comments

Let's say we have this:

matches(x)(
  async (x, xs) => {
    const thing = await somethingElse()
    ...
  },
  (x) => {

  },
)

Will this even...?

tkgalk avatar Nov 17 '17 09:11 tkgalk

Nop, but you can

matches(42)(
  (x = 42) => {
    return Promise.resolve(44444)
        .then(somethingElse)
        ...
  },
  (x) => {

  }
)

and await outside (eg: from the caller)

paulojean avatar Nov 18 '17 14:11 paulojean