DEV Community

artydev
artydev

Posted on • Updated on

Mixing Async / Sync Tasks in single workflow with RUBICO

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

Top comments (0)