-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathp-cancelable.node.txt
More file actions
30 lines (23 loc) · 1.31 KB
/
p-cancelable.node.txt
File metadata and controls
30 lines (23 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
┏━━━━━━━━━━━━━━━━━━┓
┃ P-CANCELABLE ┃
┗━━━━━━━━━━━━━━━━━━┛
VERSION ==> #4.0.1
new P-CANCELABLE
(FUNC(resolve, reject, onCancel))
PPROMISE.then(FUNC, FUNC2)
PPROMISE.catch(FUNC2)
PPROMISE.finally(FUNC3) #Inherits from Promise
PPROMISE.cancel([ERROR|'ERROR']) #Reject PPROMISE but also:
# - fire callbacks registered with onCancel()
# - if throw synchronously, PPROMISE is rejected with it instead
# - use a CancelError
#Noop if already resolved|rejected
PPROMISE.isCanceled #BOOL
onCancel(FUNC()) #Register callbacks
onCancel.shouldReject #If false (def: true), do not reject PPROMISE on cancel(). Instead only fire callbacks.
CancelError #
CANCEL_ERROR.name #'CancelError'
CANCEL_ERROR.message #Defaults to 'Promise was canceled'
fn(FUNC(...ARGS, onCancel)->PRMIS)
->FUNC2(...ARGS)
->PPROMISE #Convenience method to add onCancel to an async FUNC