Shaka Player Embedded
|
#include <promise.h>
Public Member Functions | |
Promise () | |
~Promise () override | |
Promise (const Promise &) | |
Promise (Promise &&) | |
Promise & | operator= (const Promise &) |
Promise & | operator= (Promise &&) |
bool | TryConvert (Handle< JsValue > value) override |
ReturnVal< JsValue > | ToJsValue () const override |
void | Trace (memory::HeapTracer *tracer) const override |
bool | CanResolve () const |
void | ResolveWith (Handle< JsValue > value, bool run_events=true) |
void | RejectWith (const js::JsError &error, bool run_events=true) |
void | Then (std::function< void(Any)> on_resolve, std::function< void(Any)> on_reject) |
![]() | |
virtual | ~GenericConverter () |
![]() | |
virtual | ~Traceable () |
virtual bool | IsRootedAlive () const |
virtual bool | IsShortLived () const |
Static Public Member Functions | |
static std::string | name () |
static Promise | PendingPromise () |
static Promise | Resolved () |
static Promise | Resolved (Handle< JsValue > value) |
static Promise | Rejected (const js::JsError &error) |
Additional Inherited Members | |
![]() | |
static constexpr const uint64_t | kShortLiveDurationMs = 5000 |
Defines a wrapper around a JavaScript Promise. This manages two kinds of Promises: (1) those created by us and (2) those created in JavaScript.
shaka::Promise::Promise | ( | ) |
An invalid Promise; you must use TryConvert or the assignment operator to get a valid Promise.
Definition at line 65 of file promise.cc.
|
override |
Definition at line 66 of file promise.cc.
|
default |
|
default |
|
inline |
|
inlinestatic |
|
inlinestatic |
void shaka::Promise::RejectWith | ( | const js::JsError & | error, |
bool | run_events = true |
||
) |
Definition at line 121 of file promise.cc.
|
inlinestatic |
void shaka::Promise::ResolveWith | ( | Handle< JsValue > | value, |
bool | run_events = true |
||
) |
Resolves the Promise with the given value. This can only be called if the contained Promise was created by us. Promises loaded from JavaScript (even if they were originally created by us) can't call this.
Definition at line 101 of file promise.cc.
void shaka::Promise::Then | ( | std::function< void(Any)> | on_resolve, |
std::function< void(Any)> | on_reject | ||
) |
Adds callbacks that are invoked once this Promise is resolved/rejected. These are called on the event thread. Like in JavaScript, if the Promise is already resolved/rejected, these will be called on the next loop.
Definition at line 139 of file promise.cc.
|
overridevirtual |
Converts the current value into a JavaScript value.
Implements shaka::GenericConverter.
Definition at line 87 of file promise.cc.
|
overridevirtual |
Called during a GC run. This should call HeapTracer::Trace on all Traceable members. Be sure to call the base method when overriding.
Implements shaka::memory::Traceable.
Definition at line 91 of file promise.cc.
|
overridevirtual |
Tries to convert the given value into the required type, populating the members of this object as needed.
Implements shaka::GenericConverter.
Definition at line 73 of file promise.cc.