async.Future.getState
Returns the lifecycle state: 'pending', 'fulfilled' or 'faulted'
Return value
One of the strings "pending", "fulfilled" or "faulted".
Notes
State only moves forward, and only once: pending to fulfilled or pending to faulted. Once settled, a future stays in that state for the rest of its life; a later resolve or reject call is a silent no-op and does not change what getState reports.
Example
from "async" import Future
let p = Future()
println("p.getState() =", p.getState()) // pending
p.resolve(1)
println("p.getState() =", p.getState()) // fulfilled
let q = Future()
q.reject("boom")
println("q.getState() =", q.getState()) // faulted
q.markHandled() // ack so the fault is not reported as unhandledOutput:
p.getState() = pending
p.getState() = fulfilled
q.getState() = faultedSee also
getValue | Returns the settled value (fulfilled or fault value); throws while pending. A pure peek: reading a fault does not acknowledge it (see markHandled) |
resolve | Settles a pending Future with value (default null); ignored if already settled |
reject | Faults a pending Future with value (default null); ignored if already settled |
| Future | class index |