diffusion
Version:
Diffusion JavaScript client
41 lines (37 loc) • 1.27 kB
JavaScript
var _interface = require('util/interface')._interface;
/**
* A Result represents a promise for the result of an async operation. It implements the standardised Promise/A+ spec.
*
* @class Result
* @template T onFulfilledValueType - the type of the argument to the onFullfilled callback
*/
module.exports = _interface('Result', [
/**
* Chain a Result.
*
* If the result resolves successfully, the <code>onFulfilled</code>
* callback is called with a single argument containing the value returned
* by the async operation.
*
* If the result is rejected with an error, the <code>onRejected</code>
* callback is called with a single argument containing the error that was
* raised.
*
* @param {Result.Fulfilled<T>} onFulfilled - The fulfilled callback
* @param {Result.Rejected} onRejected - The rejected callback
*
* @returns {Result<T>} A new promise
* @function Result#then
*/
'then'
]);
/**
* The callback that is invoked when a promise is fulfilled.
* @callback Result.Fulfilled
* @param {T} value - the promise value
*/
/**
* The callback that is invoked when a promise is rejected.
* @callback Result.Rejected
* @param {Error} reason - the promise rejected reason
*/