Applies the function in the left task to the value on the right task. The left task is ran to completion before the right task is started.
This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.
forall e, v1, v2:
(Task e ((v1) => v2)).(Task e v1) => Task e v2
Applies the function in the left task to the value on the right task. The left task is ran to completion before the right task is started.
Note that the right task isn't ran if the left task contains a failure.
If any of the tasks fail, the result will be that failure. Likewise, if any of the tasks is cancelled, the result will be that cancellation.
const { of, rejected } = require('folktale/concurrency/task');
const result1 = await of(x => x + 1).apply(of(1)).run().promise();
$ASSERT(result1 == 2);
try {
const result2 = await of(x => x + 1).apply(rejected(1)).run().promise();
throw 'never happens';
} catch (error) {
$ASSERT(error == 1);
}
apply(task) {
return this.chain(f => task.map(f));
}