Package org.jdeferred2
Interface Deferred<D,F,P>
- Type Parameters:
D
- Type used forresolve(Object)
F
- Type used forreject(Object)
P
- Type used fornotify(Object)
- All Superinterfaces:
Promise<D,
F, P>
- All Known Implementing Classes:
AbstractMasterDeferredObject
,AllValuesDeferredObject
,DeferredObject
,FilteredPromise
,MasterDeferredObject2
,MasterDeferredObject3
,MasterDeferredObject4
,MasterDeferredObject5
,MasterDeferredObjectN
,MasterDeferredObjectUntypedN
,PipedPromise
,SingleDeferredObject
Deferred interface to trigger an event (resolve, reject, notify).
Subsequently, this will allow Promise observers to listen in on the event
(done, fail, progress).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jdeferred2.Promise
Promise.State
-
Method Summary
Modifier and TypeMethodDescriptionThis should be called when a task is still executing and progress had been made, E.g., during a file download, notify the download progress.promise()
Return anPromise
instance (i.e., an observer).This should be called when a task has completed unsuccessfully, i.e., a failure may have occurred.This should be called when a task has completed successfully.Methods inherited from interface org.jdeferred2.Promise
always, done, fail, filter, filter, filter, isPending, isRejected, isResolved, pipe, pipe, pipe, pipeAlways, progress, state, then, then, then, waitSafely, waitSafely
-
Method Details
-
resolve
This should be called when a task has completed successfully.Deferred
deferredObject = newDeferredObject
();Promise
promise = deferredObject.promise(); promise.done(newDoneCallback
() { public void onDone(Object result) { // Done! } }); // another thread using the same deferredObject deferredObject.resolve("OK");- Parameters:
resolve
- the resolved value for thisDeferred
- Returns:
- the reference to this
Deferred
instance.
-
reject
This should be called when a task has completed unsuccessfully, i.e., a failure may have occurred.Deferred
deferredObject = newDeferredObject
();Promise
promise = deferredObject.promise(); promise.fail(newFailCallback
() { public void onFail(Object result) { // Failed :( } }); // another thread using the same deferredObject deferredObject.reject("BAD");- Parameters:
reject
- the rejected value for thisDeferred
- Returns:
- the reference to this
Deferred
instance.
-
notify
This should be called when a task is still executing and progress had been made, E.g., during a file download, notify the download progress.Deferred
deferredObject = newDeferredObject
();Promise
promise = deferredObject.promise(); promise.progress(newProgressCallback
() { public void onProgress(Object progress) { // Failed :( } }); // another thread using the same deferredObject deferredObject.reject("100%");- Parameters:
progress
- the intermediate result for thisDeferred
- Returns:
- the reference to this
Deferred
instance.
-
promise
Return anPromise
instance (i.e., an observer). You can register callbacks in this observer.- Returns:
- the reference to this
Deferred
instance as aPromise
,
-