The Task[a, b] structure represents values that depend on time. This
allows one to model time-based effects explicitly, such that one can have
full knowledge of when they're dealing with delayed computations, latency,
or anything that can not be computed immediately.
A common use for this structure is to replace the usual Continuation-Passing Style form of programming or Promises (if you prefer not to have your error catching and rejection values handled similarly), in order to be able to compose and sequence time-dependent effects using the generic and powerful monadic operations.
Signature: ((a → b) → c → void) → Task[a, b]
Parameters
Run the computation originally passed when creating the Task.
Parameters
Returns Function cancellation
Transforms the success value of the Task[_, a] using a regular unary
function.
Exposed as both a static function and a method on the Task prototype.
Signature: ((a → b) → Task[, a]) → Task[, b]
Parameters
mapperFunction
Returns Task
Transforms the fail or success values of the Task[a, b] using two regular unary
functions depending on what exists.
Exposed as both a static function and a method on the Task prototype.
Signature: ((a → b), (c → d), Task[a, c]) → Task[b, d]
Parameters
Returns Task
Transforms the success value of the Task[a, b] using a function to a
monad.
Exposed as both a static function and a method on the Task prototype.
Signature: ((b → Task[c, d]) → @Task[a, b]) → Task[c, d]
Parameters
taskMakerFunction
Returns Task
Passes both the fail and success values of the Task[a, b]
to a function that returns an Task[d, e].
Exposed as both a static function and a method on the Task prototype.
Signature: (a → Task[d, e]) → (b → Task[d, e]) → Task[d, e]
Parameters
Returns Task
Applys the success value of the Task[_, (b → c)] to the success
value of the Task[d, b]. Fails with the first failure
and throws the second away if it occurs.
Exposed as both a static function and a method on the Task prototype.
Signature: (Task[d, b] → Task[, (b → c)]) → Task[, c]
Parameters
taskValueTask
Returns Task
Take the earlier of the two Tasks
Exposed as both a static function and a method on the Task prototype.
Signature: (Task[a, b] → Task[a → b)]) → Task[a, b]
Parameters
taskATask
Returns Task
Caches the fail and success values from an Task[a, b]. Run can be called multiple times on the produced Task and the computation is not re-run.
Exposed as both a static function and a method on the Task prototype.
Signature: Task[a, b] → Task[a, b]
Returns Task
Constructs a new Task[_, b] containing the single success value b.
b can be any value, including null, undefined, or another
Task[a, b] structure.
Exposed as both a static function and a method on the Task prototype.
Signature: b → Task[_, b]
Parameters
successAny
Returns Task
Constructs a new Task[a, _] containing the single fail value a.
a can be any value, including null, undefined, or another
Task[a, b] structure.
Exposed as both a static function and a method on the Task prototype.
Signature: a → Task[a, _]
Parameters
failAny
Returns Task
Returns an Task that will never resolve
Exposed as both a static function and a method on the Task prototype.
Signature: Void → Task[_, _]
Returns Task
Alias for run.
Callback style run which passes fail and success as the first and second arguments. Use of this function is not advised as fail values are allowed to be null though you probably shouldn't be indicating a fail with null :)
Signature: (a, b) → (_ → void)
Parameters
callbackFunction
Returns Function cancel
Creates a task that sends a success if it receives a fail and passes on the value if it receives a success.
Signature: a → Task[_, a]
Parameters
elseAnyelseValue
Returns Task
Exported Factory function for Tasks. Also includes many utility methods.
Parameters
computationFunction
Returns Task
Creates a Task that sends a success after x milliseconds
Parameters
msNumbersuccessAny
Returns Task
Creates a single Task out of many that doesnt complete until each resolve with all successs or a single fail occurs. Will pass the incomplete array of successs if some have occured before a fail.
Signature: [Task[a, b]] → Task[a, [b]]
Parameters
taskArrayArray
Returns Task