-
-
Notifications
You must be signed in to change notification settings - Fork 84
Comparison of Future Implementations
Feature | Fluture | data.task | Ramda Fantasy | Fun-Task |
---|---|---|---|---|
Resource disposal | β | β | β | β |
Cancellation | β π | β π | β | β |
Nice errors | β | β | β | β |
Async utilities | β | β | β | β |
Throw safety | β | β | β | β |
High performance | β | β | β | β |
Data.task can be constructed with an extra parameter, which expects a function. The function is passed down the chain and exposed as cleanup
on the Task instances. Fluture has hook(acquire, cleanup, consume)
for managing resources.
Fluture has cancellation in its current beta release. Data.Task is being reworked from the ground up to include cancellation. More information in this issue comment: https://github.com/folktale/data.task/issues/35#issuecomment-220660291. FunTask has been created to include cancellation from the beginning.
Most libraries don't perform any kind of type-checking on arguments passed. This often leads to very difficult to understand error messages. Fluture is the exception:
FunTask.of('world').chain(thing => `Hello ${thing}!`).run({success: console.log, failure: console.error})
TypeError: spawned.run is not a function
at fun-task/lib/index.js:702:33
at success (fun-task/lib/index.js:682:32)
at Of._run (fun-task/lib/index.js:376:7)
> DataTask.of('world').chain(thing => `Hello ${thing}!`).fork(console.error, console.log)
TypeError: f(...).fork is not a function
at data.task/lib/task.js:117:19
at data.task/lib/task.js:58:12
at Task.fork (data.task/lib/task.js:114:12)
> RamdaFuture.of('world').chain(thing => `Hello ${thing}!`).fork(console.error, console.log)
[TypeError: f(...).fork is not a function]
> Fluture.of('world').chain(thing => `Hello ${thing}!`).fork(console.error, console.log)
TypeError: Future#chain expects the function its given to return a Future
Actual: "Hello world!"
From calling: thing => `Hello ${thing}!`
With: "world"
at check$chain$f (fluture/fluture.js:103:29)
at Future$chain$res (fluture/fluture.js:229:9)
at Object.Future$of$fork [as _f] (fluture/fluture.js:214:7)
Ramda Fantasy only has Future.cache(). Data.task can be installed with control.async to gain async control utilities. Fluture comes bundled with async control utilities.
Ramda Fantasy prevents thrown errors from ever breaking out. When an error is thrown within one of the functions called by Ramda Fantasy, it ends up in the rejection branch of the Future. This is arguably not a good thing, as documented by this section on error handling. FunTask can catch thrown errors for you, and separates them to a third branch.
Fluture and Data.Task have significantly better performance than other similar libraries.