Constructor
# new Deferred()
Constructs a deferred object.
- Source:
Example
import { Deferred, asyncRoot, sleep } from 'modern-async'
asyncRoot(async () => {
const deferred = new Deferred()
sleep(10).then(() => {
deferred.resolve('test')
})
console.log(await deferred.promise) // will wait 10ms before printing 'test'
})
Members
# promise :Promise
(Read-only) The promise.
Type:
- Promise
- Source:
# reject :function
(Read-only) The reject function
Type:
- function
- Source:
# resolve :function
(Read-only) The resolve function.
Type:
- function
- Source: