-
Notifications
You must be signed in to change notification settings - Fork 2
Decorators
DigitalBrainJS edited this page Oct 17, 2021
·
1 revision
const promise= test.asyncMethod();
### @timeout(ms: Number)
Sets the timeout option for the CPromise async function.
### @innerWeight(weight: Number)
Sets the innerWeight option for the CPromise async function.
### @label(label: String)
Sets the label option for the CPromise async function.
### @done([doneHandler(value, isRejected, scope, context)])
Decorates async function with `done` chain
### @atomic([atomicType: 'disabled'|'detached'|'await'|true|false])
Configures decorated CPromise async function as atomic.
## Events
All events (system and user defined) can be fired only when promises in pending state.
Predefined (system) events:
- `cancel(reason: CanceledError)` - fires when promise is canceled (rejected with `CanceledError`)
- `pause` - on promise pause request
- `resume` - on promise resume request
- `capture(scope: CPromise)` - fired when some consumer directly or above standing in the chain starts progress capturing
- `progress(value: Number, scope: CPromise, data: Object?)` - fired when promise chain progress changes
Event listener attaching shortcuts (methods bound to the promise instance):
- `onCancel(listener: Function)`
- `onPause(listener: Function)`
- `onResume(listener: Function)`
- `onCapture(listener: Function)`