A promise. More...
Public Member Functions | |
fm.liveswitch.Future< T > | fail (fm.liveswitch.IAction1< java.lang.Exception > rejectAction) |
Appends a handler to be executed when the promise is rejected. More... | |
fm.liveswitch.Future< T > | fail (fm.liveswitch.IFunction1< java.lang.Exception, fm.liveswitch.Future< T >> rejectFunction) |
Appends a handler to be executed when the promise is rejected. More... | |
Promise () | |
Creates a new promise. More... | |
Promise (fm.liveswitch.IAction2< fm.liveswitch.IAction1< T >, fm.liveswitch.IAction1< java.lang.Exception >> callback) | |
Creates a promise with a resolve callback and a reject callback. More... | |
fm.liveswitch.Future< T > | then (fm.liveswitch.IAction1< T > resolveAction) |
Appends a handler to be executed when the promise is resolved. More... | |
fm.liveswitch.Future< T > | then (fm.liveswitch.IAction1< T > resolveAction, fm.liveswitch.IAction1< java.lang.Exception > rejectAction) |
Appends handlers to be executed when the promise is resolved or rejected. More... | |
Public Member Functions inherited from fm.liveswitch.PromiseBase< T > | |
boolean | castAndResolve (Object result) |
Casts the result and resolves the promise. More... | |
String | getId () |
Gets the identifier of this promise. More... | |
PromiseBase () | |
Initializes a new instance of the fm.liveswitch.PromiseBase class. More... | |
boolean | reject (java.lang.Exception exception) |
Rejects the promise. More... | |
fm.liveswitch.Future< Object > | rejectAsync (java.lang.Exception exception) |
Rejects the promise asynchronously. More... | |
boolean | resolve (T result) |
Resolves the promise. More... | |
fm.liveswitch.Future< Object > | resolveAsync (T result) |
Resolves the promise asynchronously. More... | |
Public Member Functions inherited from fm.liveswitch.Future< T > | |
void | waitForPromise () |
Blocks the current thread from proceeding until the future state has been resolved or rejected. More... | |
void | waitForPromise (int millisecondsTimeout) |
Blocks the current thread from proceeding until the future state has been resolved or rejected or if the timeout period elapses. More... | |
T | waitForResult () |
Blocks the current thread from proceeding until the future has a result. More... | |
T | waitForResult (int millisecondsTimeout) |
Blocks the current thread from proceeding until the future has a result. More... | |
Public Member Functions inherited from fm.liveswitch.FutureBase< T > | |
java.lang.Exception | getException () |
Gets the exception if rejected. More... | |
T | getResult () |
Gets the result if resolved. More... | |
fm.liveswitch.FutureState | getState () |
Gets the current state. More... | |
Static Public Member Functions | |
static fm.liveswitch.Future< Object > | wrap (fm.liveswitch.IAction0 callbackAction) |
Creates a promise and resolves it after invoking a callback action, or rejects it if an exception is thrown. More... | |
static< R extends Object > fm.liveswitch.Future< R > | wrap (fm.liveswitch.IFunction0< R > callbackFunction) |
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown. More... | |
static fm.liveswitch.Future< Object > | wrapAsync (fm.liveswitch.IAction0 callbackAction) |
Creates a promise and resolves it after invoking a callback action, or rejects it if an exception is thrown. More... | |
static< R extends Object > fm.liveswitch.Future< R > | wrapAsync (fm.liveswitch.IFunction0< R > callbackFunction) |
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown. More... | |
Static Public Member Functions inherited from fm.liveswitch.PromiseBase< T > | |
static< R extends Object > fm.liveswitch.Future< R > | all (fm.liveswitch.Future< R >[] promises) |
Returns a promise that resolves when all passed in promises resolve. More... | |
static< R extends Object > fm.liveswitch.Future< R > | any (fm.liveswitch.Future< R >[] promises) |
Returns a promise that resolves when any passed in promise resolves. More... | |
static< R extends Object > fm.liveswitch.Future< R > | delay (int delayMs) |
Create a promise that resolves afer a delay. More... | |
static< R extends Object > fm.liveswitch.Future< R > | rejectNow (java.lang.Exception ex) |
Creates a promise and rejects it immediately. More... | |
static fm.liveswitch.Future< Object > | resolveNow () |
Creates a promise and resolves it immediately using a null result value. More... | |
static< R extends Object > fm.liveswitch.Future< R > | resolveNow (R result) |
Creates a promise and resolves it immediately using the given result value. More... | |
static< R extends Object > fm.liveswitch.Future< R > | wrapPromise (fm.liveswitch.IFunction0< fm.liveswitch.Future< R >> callback) |
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from fm.liveswitch.PromiseBase< T > | |
void | process (fm.liveswitch.IPromise promise, fm.liveswitch.IAction1< T > resolve, fm.liveswitch.IAction1< java.lang.Exception > reject) |
Processes the specified promise. More... | |
Protected Member Functions inherited from fm.liveswitch.Future< T > | |
Future () | |
Protected Member Functions inherited from fm.liveswitch.FutureBase< T > | |
FutureBase () | |
void | setException (java.lang.Exception value) |
Sets the exception if rejected. More... | |
void | setResult (T value) |
Sets the result if resolved. More... | |
void | setState (fm.liveswitch.FutureState value) |
Sets the current state. More... | |
A promise.
fm.liveswitch.Promise< T >.Promise | ( | ) |
Creates a new promise.
fm.liveswitch.Promise< T >.Promise | ( | fm.liveswitch.IAction2< fm.liveswitch.IAction1< T >, fm.liveswitch.IAction1< java.lang.Exception >> | callback | ) |
Creates a promise with a resolve callback and a reject callback.
fm.liveswitch.Future<T> fm.liveswitch.Promise< T >.fail | ( | fm.liveswitch.IAction1< java.lang.Exception > | rejectAction | ) |
Appends a handler to be executed when the promise is rejected.
rejectAction | The reject action. |
Reimplemented from fm.liveswitch.Future< T >.
fm.liveswitch.Future<T> fm.liveswitch.Promise< T >.fail | ( | fm.liveswitch.IFunction1< java.lang.Exception, fm.liveswitch.Future< T >> | rejectFunction | ) |
Appends a handler to be executed when the promise is rejected.
rejectFunction | The reject function. |
Reimplemented from fm.liveswitch.Future< T >.
fm.liveswitch.Future<T> fm.liveswitch.Promise< T >.then | ( | fm.liveswitch.IAction1< T > | resolveAction | ) |
Appends a handler to be executed when the promise is resolved.
resolveAction | The resolve action. |
Reimplemented from fm.liveswitch.Future< T >.
fm.liveswitch.Future<T> fm.liveswitch.Promise< T >.then | ( | fm.liveswitch.IAction1< T > | resolveAction, |
fm.liveswitch.IAction1< java.lang.Exception > | rejectAction | ||
) |
Appends handlers to be executed when the promise is resolved or rejected.
resolveAction | The resolve action. |
rejectAction | The reject action. |
Reimplemented from fm.liveswitch.Future< T >.
|
static |
Creates a promise and resolves it after invoking a callback action, or rejects it if an exception is thrown.
callbackAction | The callback action. |
|
static |
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown.
callbackFunction | The callback function. |
|
static |
Creates a promise and resolves it after invoking a callback action, or rejects it if an exception is thrown.
The callback is always dispatched to the background.
callbackAction | The callback action. |
|
static |
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown.
The callback is always dispatched to the background.
callbackFunction | The callback function. |