Class: shaka.polyfill.Promise
A polyfill to implement Promises, primarily for IE.
Only partially supports thenables, but otherwise passes the A+ conformance
tests.
Note that Promise.all() and Promise.race() are not tested by that suite.
Constructor
new Promise(opt_callbackopt)
A polyfill to implement Promises, primarily for IE.
Only partially supports thenables, but otherwise passes the A+ conformance
tests.
Note that Promise.all() and Promise.race() are not tested by that suite.
Parameters:
Name |
Type |
Attributes |
Description |
opt_callback |
function(function(*=), function(*=))=
|
<optional>
|
|
- Source:
Members
(private, static, nullable) flushTimer_ :number
A timer ID to flush the queue.
Type:
- Source:
(private, static) nativePromise_ :?
Type:
- Source:
(private, static, non-null) q_ :Array.<function()>
A queue of callbacks to be invoked ASAP in the next frame.
Type:
- Source:
(static) State :number
Type:
Properties:
Name |
Value |
Type |
Description |
PENDING |
0
|
number
|
|
RESOLVED |
1
|
number
|
|
REJECTED |
2
|
number
|
|
- Source:
(private) value_ :*
Type:
- Source:
Methods
Parameters:
Name |
Type |
Description |
id |
number
|
Clear a scheduled callback.
Bound in shaka.polyfill.Promise.install() to a specific implementation. |
- Source:
(static) flush()
Flush the queue of callbacks.
Used directly by some unit tests.
- Source:
(private, static) handleThenable_(thenablenon-null, then, childnon-null)
Parameters:
- Source:
(static) install(opt_forceopt)
Install the polyfill if needed.
Parameters:
Name |
Type |
Attributes |
Description |
opt_force |
boolean
|
<optional>
|
If true, force the polyfill to be installed.
Used in some unit tests. |
- Source:
Parameters:
Name |
Type |
Description |
callback |
function()
|
|
- Source:
Returns:
Schedule a callback as soon as possible.
Bound in shaka.polyfill.Promise.install() to a specific implementation.
-
Type
-
number
(static) uninstall()
Uninstall the polyfill. Used in some unit tests.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
opt_callback |
function(*)=
|
<optional>
|
|
- Source:
Returns:
-
Type
-
shaka.polyfill.Promise
(private) reject_(opt_reasonopt)
Parameters:
Name |
Type |
Attributes |
Description |
opt_reason |
*
|
<optional>
|
|
- Source:
(private) resolve_(opt_valueopt)
Parameters:
Name |
Type |
Attributes |
Description |
opt_value |
*
|
<optional>
|
|
- Source:
(private) schedule_(childnon-null, callback)
Parameters:
- Source:
then(opt_successCallbackopt, opt_failCallbackopt) → (non-null) {shaka.polyfill.Promise}
Parameters:
Name |
Type |
Attributes |
Description |
opt_successCallback |
function(*)=
|
<optional>
|
|
opt_failCallback |
function(*)=
|
<optional>
|
|
- Source:
Returns:
-
Type
-
shaka.polyfill.Promise
Type Definitions
Child
A child promise, used for chaining.
Only exists in the context of a then or catch chain.
Type:
Properties:
Name |
Type |
Description |
promise |
shaka.polyfill.Promise
|
The child promise. |
callback |
function
|
undefined
|
The then or catch callback to be invoked as part of this chain. |
- Source: