listen

Adds a visitor to be invoked when the deferred's state changes.

Signature

listen(pattern)
('a: Deferred 'f 's).(DeferredListener 'f 's) => Void

Documentation

Adds a visitor to be invoked when the deferred's state changes.

Properties

Source Code

Defined in source/concurrency/future/_deferred.js at line 58, column 21
listen(pattern) {
    this._state.matchWith({
      Pending:   _            => this._listeners.push(pattern),
      Cancelled: _            => pattern.onCancelled(), 
      Resolved:  ({ value })  => pattern.onResolved(value),
      Rejected:  ({ reason }) => pattern.onRejected(reason)
    });
    return this;
  }
Licence
MIT
Module
folktale/concurrency/future/_deferred
On This Page
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)