1. 21
    Refactor a Promise Chain to Function Composition using Ramda
    8m 37s

Refactor a Promise Chain to Function Composition using Ramda

Share this video with your friends

Send Tweet

Promise chains can be a powerful way to handle a series of transformations to the results of an async call. In some cases, additional promises are required along the way. In cases where there are no new promises, function composition can reduce the number of dot chained thens you need. In this lesson, we'll look at how to take a promise chain, and reduce it down with function composition.

Thinh
Thinh
~ 8 years ago

composeP can also be used.

Andy Van Slaars
Andy Van Slaars(instructor)
~ 8 years ago

Thinh,

It certainly can be, but the maintainers have been discussing deprecating the promise-specific versions of compose and pipe, This approach is less likely to go out of date with a future release of Ramda.

You can read more here if you're interested - https://github.com/ramda/ramda/pull/1869

Thanks for watching and for pointing this out for others.

Yegor Belov
Yegor Belov
~ 6 years ago

in my experience it's safer to use R.path() or R.pathOr() instead of R.prop() even if there's no nesting. path() is bullet-proof against undefined values, while prop() will break