added sync/async task start option on task creation...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-11-27 01:53:14 +03:00
parent fcb018b67a
commit 0f7640e11f
2 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "ig-types",
"version": "5.0.17",
"version": "5.0.18",
"description": "Generic JavaScript types and type extensions...",
"main": "main.js",
"scripts": {

View File

@ -503,10 +503,21 @@ object.Constructor('TaskManager', Array, events.EventMixin('flat', {
// ...this needs to work with all the event methods...
Task: function(title, task, ...args){
var that = this
var _args = [...arguments]
// parse args...
var sync_start = this.sync_start
if(title == 'sync' || title == 'async'){
;[sync_start, title, task, ...args] = _args
sync_start = sync_start == 'sync'
} else if(task == 'sync' || task == 'async'){
;[title, sync_start, task, ...args] = _args
sync_start = sync_start == 'sync' }
// anonymous task...
if(typeof(title) != typeof('str')){
;[task, ...args] = arguments
;[task, ...args] = _args
title = null }
// normalize handler...
@ -582,7 +593,7 @@ object.Constructor('TaskManager', Array, events.EventMixin('flat', {
task.start()
: null }
// trigger task start...
this.sync_start ?
sync_start ?
start()
: setTimeout(start, 0)