-
-
Notifications
You must be signed in to change notification settings - Fork 0
async_extensions
j-show edited this page Mar 1, 2019
·
2 revisions
- Note
- Consolidate the list of callback functions in the form of arrays
- Centralized control trigger form
- Inherited from
TSeal
- Class Function
-
create(opt, limit, callback)
- Note
- Class object Initialization
- Parameters
-
[opt]
Core parameters-
opt.memory=false
Whether to remember the last trigger state -
opt.fire=false
Whether to trigger automatically -
opt.once=true
Whether to call a callback only once -
opt.unique=false
Whether to allow function repetition
-
-
limit
Upper limit of callback function -
callback
callback function after all callbacks are triggered
-
- Return
- object
- Note
-
- Object Function
-
lock()
- Note
- Lock object, no trigger callback is allowed after locking
- Return
- Return boolean
- Note
-
unlock()
- Note
- Unlock
- Return
- Return boolean
- Note
-
on([func...])
- Note
- Add callback function
- Parameters
-
func
callback function- Allow array of callback functions
-
- Return
- this
- Note
-
off(func)
- Note
- Delete callback function
- Parameters
-
func
Deletes the specified callback function
-
- Return
- this
- Note
-
fire()
- Note
- Trigger callback function
- Parameters
- Parameters will be brought into all callback functions
- Return
- this
- Note
-
fireWith(own, [args], [done])
- Note
- Trigger the callback function with the parameter own as this
- Parameters
-
own
this replaces the object -
args
Parameters that trigger callbacks -
done
When all callbacks are complete, the trigger function
-
- Return
- this
- Note
-
unique()
- Note
- Delete duplicate callback function, invalid when locking state
- Return
- this
- Note
-
has(func)
- Note
- Determine if the callback function repeats
- Return
- this
- Note
-
- Property
-
length
- Note
- Number of callback functions
- Readonly
- Return
- number
- Note
-
locked
- Note
- Whether the state is locked
- Read & Write
- Return
- boolean
- Note
-
- Note
- Asyn extension class, observer mode
- Asynchronous processing based on TCallback class in a manner consistent with jQuery's deferred
- Inherited from
TSeal
- Class Function
-
create(limit, callback)
- Note
- Class object Initialization
- Parameters
-
limit
Upper limit of callback function -
callback
callback function after all callbacks are triggered
-
- Return
- object
- Note
-
- Object Function
-
promise([own], [max])
- Note
- Return Promise object
- By setting max, you can use the
notify
function to trigger progress events - Deferred object must use the return object of the Promise function for the function to trigger the event
- Parameters
-
own
this object of the callback function -
max
Maximum number of triggers for progress events
-
- Return
- this
- Note
-
done(func)
- Note
- Binding Success Event callback function, allowing multiple bindings
- Triggered by the
resolve
function
- Parameters
-
func
callback function
-
- Return
- this
- Note
-
fail(func)
- Note
- Binding failed event callback function that allows multiple bindings
- Triggered by the
reject
function
- Parameters
-
func
callback function
-
- Return
- this
- Note
-
always(func)
- Note
- Binding completes event callback function, allowing multiple bindings
- Triggered after
done
,fail
events
- Parameters
-
func
callback function
-
- Return
- this
- Note
-
warn(func)
- Note
- Binding Warning Event callback function, allowing multiple bindings
- Warning event allows multiple triggers
- triggered by the
alarm
function
- Parameters
-
func
callback function
-
- Return
- this
- Note
-
progress(func)
- Note
- Binding Progress event callback function, allowing multiple bindings
- Progress events allow multiple triggers
- triggered by the
notify
function,Automatically triggers the `done' function when the number of triggers reaches the upper limit
- Parameters
-
func
callback function
-
- Return
- this
- Note
-
resolve(arg)
- Note
- Trigger
done
event
- Trigger
- Parameters
-
arg
Passing parameters
-
- Return
- this
- Note
-
reject(arg)
- Note
- Trigger
fail
event
- Trigger
- Parameters
-
arg
Passing parameters
-
- Return
- this
- Note
-
alarm(arg)
- Note
- Trigger
warn
event
- Trigger
- Parameters
-
arg
Passing parameters
-
- Return
- this
- Note
-
notify(arg)
- Note
- Trigger
progress
event
- Trigger
- Parameters
-
arg
Passing parameters
-
- Return
- this
- Note
-
- Property
-
state
- Note
- Current asynchronous state
- Readonly
- Return
- number
- Note
-
- Note
- Extending asynchronous chained objects
- Function Extensions for Promise
- Class Function
-
create([callback], [simple=false])
- Note
- Class object Initialization
- Parameters
-
callback
callback function after all callbacks are triggered -
simple
Whether it's a simple mode- simple=true,
warn
、progress
Event takes effect - simple=false,
warn
、progress
Invalid event
- simple=true,
-
- Return
- object
- Note
-
- Object Function
-
promise([max])
- Note
- Return Promise object
- By setting max, you can use the
notify
function to trigger progress events
- Parameters
-
max
Maximum number of triggers for progress events
-
- Return
- Promise object
- Note
-
done(func)
- Note
- Binding Success Event callback function, allowing multiple bindings
- Triggered by the
resolve
function
- Parameters
-
func
callback function
-
- Return
- this
- Note
-
fail(func)
- Note
- Binding failed event callback function that allows multiple bindings
- Triggered by the
reject
function
- Parameters
-
func
callback function
-
- Return
- this
- Note
-
always(func)
- Note
- Binding completes event callback function, allowing multiple bindings
- Triggered after
done
、fail
event
- Parameters
-
func
callback function
-
- Return
- this
- Note
-
warn(func)
- Note
- Binding Warning Event callback function, allowing multiple bindings
- Warning event allows multiple triggers
- triggered by the
alarm
function
- Parameters
-
func
callback function
-
- Return
- this
- Note
-
progress(func)
- Note
- Binding Progress event callback function, allowing multiple bindings
- Progress events allow multiple triggers
- triggered by the
notify
function,Automatically triggers the `done' function when the number of triggers reaches the upper limit
- Parameters
-
func
callback function
-
- Return
- this
- Note
-
resolve(arg)
- Note
- Trigger
done
event
- Trigger
- Parameters
-
arg
Passing parameters
-
- Return
- this
- Note
-
reject(arg)
- Note
- Trigger
fail
event
- Trigger
- Parameters
-
arg
Passing parameters
-
- Return
- this
- Note
-
alarm(arg)
- Note
- Trigger
warn
event
- Trigger
- Parameters
-
arg
Passing parameters
-
- Return
- this
- Note
-
notify(arg)
- Note
- Trigger
progress
event
- Trigger
- Parameters
-
arg
Passing parameters
-
- Return
- this
- Note
-
- Note
- Get callback management objects through functions, centralize management callback lists, and uniformly trigger
- Parameters
-
flag=once memory limit
Callback Object label- Label definition, same as TCallback class
-
limit=50
Callback List Upper Limit -
callback
When the callback list trigger is complete, the triggered function
-
- Return
- Return TCallback object
- Note
- Asynchronous Operation objects
- Suitable for different asynchronous modes based on simple parameters
- Parameters
-
simple
Asynchronous mode- simple=true,Simple mode, based on TPromise class, can be adapted to async/awit asynchronous operation
- simple=false,Complex mode, based on TDeferred class, can be adapted to all environments
- simple is number,Complex mode, based on TDeferred class, Simple is the upper limit of the callback function
-
callback
End callback, triggered after always event is complete
-
- Return
- Return TDeferred/TPromise object
- Note
- Promise Extended Objects
- Based on TPromise
- Parameters
-
callback
callback function after all callbacks are triggered
-
- Return
- Return TPromise object
- Note
- Generator function converted to Promise object
- Parameters
-
gen
Generator function -
data
Successful trigger parameters -
owner
Replace this object
-
- Return
- Return Promise object
- Note
- normal function converted to async function
- Trigger
done
event
- Parameters
-
func
normal function
-
- Return
- Return TPromise object
- WebBrowser
- Node.js