Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: async version of map, andThen #33

Open
Jack-Works opened this issue Aug 3, 2021 · 4 comments
Open

Feature request: async version of map, andThen #33

Jack-Works opened this issue Aug 3, 2021 · 4 comments

Comments

@Jack-Works
Copy link
Contributor

result.andThen(async e => calc(e))
@shalexbas
Copy link

This feature would be perfect! I know there is ts-async-results Lib but this lib is not used a lot and mainted by just one person. I would like to see this feature in this great lib, because there are a lot cases where you need async functions like encryption, webcalls, ... which would naturally produce a Result.

@andreitopli
Copy link

@shalexbas I agree with you. We have been using ts-async-result in production extensively on https://www.chessroulette.live and it works perfectly, haven't encountered any issues yet. I think there's a thread here opened about merging ts-async-results into this library.

@GabrielCTroia
Copy link

Or someone could help me maintain it 😁! But yeah, we’ve been using it extensively at chessroulette so we will hopefully be able to put more resources into it as we grow.

@ctsstc
Copy link

ctsstc commented Apr 13, 2023

I was looking around for this, but I'm sad to find this open ticket that such does not exist.

For now I'll continue with this pattern:

async function anAsyncMethod(): Promise<Result<SomeType, SomeError>> {
  const result = await someAsyncCall()

  if (result.ok) {
    return await someOtherAsyncCall()
  }

  return result
}

async function someAsyncCall(): Promise<Result<SomeType, SomeError>> {}

async function someOtherAsyncCall(): Promise<Result<SomeType, SomeError>> {}

There's also scenarios where you may have to map the types as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants