You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.map(_.wrapCallback).invoke('call) has become a rather common pattern for me in refactoring from async to Highland, I think enough to consider making an alias, perhaps .call(). It could also potentially take an args list, deal with this nicely, etc.
Beyond convenience, this would also make it easier to draw parallels between some of async's control flow functions and Highland, much like caolan's first comment in #79 does for some of async's collection functions. Some examples:
.call().series() to async.series() .call().parallel() to async.parallel() .call(args) to async.applyEach(..., args) .call(args).series() to async.applyEachSeries(..., args)
As a bonus, we can just use Function.prototype.bind() much like async uses async.apply:
This is really mostly because we have _.wrapCallback doing part of what async.apply does; we could always map async.apply similarly, but that gets long.
See also this SO post, where .call would've come in handy or even avoided the question entirely. The example from it:
function firstThing(state, next) {
state.firstThingDone = true;
setImmediate(next);
}
function secondThing(state, next) {
state.secondThingDone = true;
setImmediate(next);
}
var state = {};
async.applyEachSeries([
firstThing,
secondThing
], state, function (error) {
console.log(error, state);
});
Of course, I'm not looking to just port over async functions, but I think this one addition might go a long way, especially in making it easier for async people to pick up Highland.
The text was updated successfully, but these errors were encountered:
.map(_.wrapCallback).invoke('call)
has become a rather common pattern for me in refactoring from async to Highland, I think enough to consider making an alias, perhaps.call()
. It could also potentially take anargs
list, deal withthis
nicely, etc.Beyond convenience, this would also make it easier to draw parallels between some of async's control flow functions and Highland, much like caolan's first comment in #79 does for some of async's collection functions. Some examples:
.call().series()
toasync.series()
.call().parallel()
toasync.parallel()
.call(args)
toasync.applyEach(..., args)
.call(args).series()
toasync.applyEachSeries(..., args)
As a bonus, we can just use
Function.prototype.bind()
much like async usesasync.apply
:This stays nice when we actually need to use bind, while async gets messy:
This is really mostly because we have
_.wrapCallback
doing part of whatasync.apply
does; we could always mapasync.apply
similarly, but that gets long.See also this SO post, where
.call
would've come in handy or even avoided the question entirely. The example from it:lines straight up with:
(don't mind the
.toArray
where.done
would fit)Of course, I'm not looking to just port over async functions, but I think this one addition might go a long way, especially in making it easier for async people to pick up Highland.
The text was updated successfully, but these errors were encountered: