类名 Promise

# new Promise()

Trusted Promise constructor. A Promise created from this constructor is a trusted when.js promise. Any other duck-typed promise is considered untrusted.

方法

# always(onFulfilledOrRejectedopt, nullable, onProgressopt, nullable)

Register a callback that will be called when a promise is fulfilled or rejected. Optionally also register a progress handler. Shortcut for .then(onFulfilledOrRejected, onFulfilledOrRejected, onProgress)

参数:

名称 类型 描述
onFulfilledOrRejected function
onProgress function
Promise

# otherwise(onRejectednullable)

Register a rejection handler. Shortcut for .then(undefined, onRejected)

参数:

名称 类型 描述
onRejected function
Promise

# spread(onFulfilled)

Assumes that this promise will fulfill with an array, and arranges for the onFulfilled to be called with the array as its argument list i.e. onFulfilled.spread(undefined, array).

参数:

名称 类型 描述
onFulfilled function

function to receive spread arguments

Promise

# yield(value)

Shortcut for .then(function() { return value; })

参数:

名称 类型 描述
value *

a promise that:

  • is fulfilled if value is not a promise, or
  • if value is a promise, will fulfill with its value, or reject with its reason.
Promise
构造函数
成员变量
方法
事件