bahmutov / vo-task

Wraps data.task around VO async function
4 stars 0 forks source link

Should we curry / combine arguments? #3

Open bahmutov opened 8 years ago

bahmutov commented 8 years ago

We could combine arguments to the initial wrap and the final task making call

function add(a, b) { return a + b }
const makeAdd2 = voTask(add, 2)
const add2to5 = makeAdd2(5)
add2to5.fork(...) // result is 7
bahmutov commented 8 years ago

This will allow simple partial application, unlike this

function add(a, b) { return a + b }
const makeAdd2 = voTask(add.bind(null, 2))
const add2to5 = makeAdd2(5)
add2to5.fork(...) // result is 7

We have to use Function.prototype.bind because voTask works well with generators, while partial application utils, like lodash _.partial do not work with generators.