apply

Transforms the succesful value of a future by using a function stored in another future.

This feature is experimental!

This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.

Signature

value(future)
(Future 'f 's).(Future 'f (('s) => 's2)) => Future 'f 's2

Documentation

Transforms the succesful value of a future by using a function stored in another future.

Example:

const { of, rejected } = require('folktale/concurrency/future');

const inc = (x) => x + 1;

of(inc).apply(of(1)).listen({
  onResolved: (value) => $ASSERT(value == 2)
});

rejected(inc).apply(of(1)).listen({
  onRejected: (reason) => $ASSERT(reason === inc)
});

of(inc).apply(rejected(1)).listen({
  onRejected: (reason) => $ASSERT(reason == 1)
});

Properties

Source Code

Defined in source/concurrency/future/_future.js at line 24, column 0
apply(future) {
    return this.chain(fn => future.map(fn));
  }
Stability
experimental
Licence
MIT
Module
folktale/concurrency/future/_future
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)