1. 1
    Refactor to Point Free Functions with Ramda using compose and converge
    3m 33s

Refactor to Point Free Functions with Ramda using compose and converge

Share this video with your friends

Send Tweet

In this lesson we'll take some existing code and refactor it using some functions from the Ramda library, most notably, compose and converge. When we're done, we'll have taken a function with a couple of local variables and parameter references and converted it into more streamlined "point-free" or "tacit" functions.

Brendan Whiting
Brendan Whiting
~ 6 years ago

I don't understand the benefit here. We could have just added a default value to the id parameter in case it was null:

const generateUrl = (id = 'default') => `https://img.socialnetwork.com/avatar/${id}.png`

The way we've refactored with Ramda is looks more confusing and harder to understand. I'm not familiar with Ramda yet maybe I'll see the point by the end of the course.

Eliezer Steinbock
Eliezer Steinbock
~ 5 years ago

How is this the first episode of the series? It just jumps right in without explaining half of what is going on?

Per
Per
~ 5 years ago

Very tough for a first lesson. Watched it several times and it's still hard to grasp. End result is not very clear to read either. Must be better examples to show benefits of ramda.

Robert Pearce
Robert Pearce
~ 5 years ago

@Brendan, in your example, if generateUrl is called with null, then your result will be "https://img.socialnetwork.com/avatar/null.png", which is not what you want.

Gerald Yeo
Gerald Yeo
~ 4 years ago

With the new nullish coalescing operator, we only need to do this:

const generateUrl = (id) => `https://img.socialnetwork.com/avatar/${id ?? 'default'}.png`
Tre' Codez
Tre' Codez
~ 4 years ago

I don't understand the benefit here. We could have just added a default value to the id parameter in case it was null:

Off the cuff, I'd say composability.