DEV Community

loading...

Mixing Async / Sync Tasks in single workflow with RUBICO

artydev profile image artydev ・1 min read

Awesome library which allows to compose async and sync functions with ease.

Don't conviced ? Look at the following code.
The requests are treated in parallel.

You can try it here : RubicoTest

const { pipe, map } = rubico

const toTodosUrl = id => `https://jsonplaceholder.typicode.com/todos/${id}`

const logTodoByID = pipe([ // fetch a Todo and log it
  toTodosUrl,
  fetch,
  response => response.json(),
  console.log,
])

const todoIDs = [1, 2, 3, 4, 5]

map(logTodoByID)(todoIDs)

Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide