question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chain over the "rejected" side of an `Async`

See original GitHub issue

I would like to request the ability to chain over the left or “rejected” side of an Async. This would be helpful to move values from the left side of the Async to the right.

getAsync()
  .chainRej(ifElse(isErrorOk, constant(Async.of('Error Ignored')), Async.Rejected))

I’m currently doing this with a helper function.

// chainRej :: (a -> Async e a) -> Async a b -> Async e a|b
export const chainRej = curry((fn, a) =>
  Async((rej, res) => a.fork(x => fn(x).fork(rej, res), res))
)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
mgreystonecommented, Apr 26, 2019

bichain sounds like a win to me.

1reaction
dalefrancis88commented, Jul 17, 2019

@mgreystone There is a PR ready for bichain sitting here, https://github.com/evilsoft/crocks/pull/394 if you have time, check it out and let me know if you see any opportunities for improvement

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unhandle rejection promise async await chain - Stack Overflow
In the analyze() you are returning Project.reject() but analyze() is an async function. Therefor it resolves any value that you return and ...
Read more >
Promises chaining - The Modern JavaScript Tutorial
In this chapter we cover promise chaining. It looks like this: new Promise(function(resolve, reject) { setTimeout(() => resolve(1), 1000); ...
Read more >
JavaScript Promise Tutorial: Resolve, Reject, and Chaining in ...
Representation of the process of Promises​​ But if we don't get the information, then the Promise will be in the rejected state. Additionally,...
Read more >
Handling those unhandled promise rejections with JS async ...
The Problem · You put your code inside an async function in order to use await calls · You put an await call...
Read more >
async function - JavaScript - MDN Web Docs - Mozilla
In concurrentPromise , Promise.all wires up the promise chain in one go, meaning that the operation will fail-fast regardless of the order of ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found