fixed a couple of issues...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-12-04 06:16:54 +03:00
parent 4414bd0e7a
commit f9930bf6b9
4 changed files with 31 additions and 21 deletions

View File

@ -2531,6 +2531,8 @@ function(func){
// during the later form 'sync' is passed to .Task(..) in the correct // during the later form 'sync' is passed to .Task(..) in the correct
// position... // position...
// (see ig-types' runner.TaskManager(..) for more info) // (see ig-types' runner.TaskManager(..) for more info)
//
// XXX use action.name to identify the task instead of the title...
var taskAction = var taskAction =
module.taskAction = module.taskAction =
function(title, func){ function(title, func){
@ -2542,8 +2544,8 @@ function(title, func){
.pop() .pop()
var action var action
return (action = object.mixin( return (object.mixin(
Task(function(...args){ action = Task(function(...args){
if(args[0] == 'sync' || args[0] == 'async'){ if(args[0] == 'sync' || args[0] == 'async'){
pre_args = [args.shift(), title] } pre_args = [args.shift(), title] }
return this.tasks.Task(...pre_args, func.bind(this), ...args) }), return this.tasks.Task(...pre_args, func.bind(this), ...args) }),
@ -2604,15 +2606,18 @@ function(name, func){
func = args.pop() func = args.pop()
var [name, opts] = args var [name, opts] = args
var action
return object.mixin( return object.mixin(
Queued(function(...args){ action = Queued(function(...args){
var that = this var that = this
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
that.queue(name, opts || {}) Object.assign(
.push(function(){ that.queue(name, opts || {})
var res = func.call(that, ...args) .push(function(){
resolve(res) var res = func.call(that, ...args)
return res }) }) }), resolve(res)
return res }),
{ title: action.name }) }) }),
{ {
toString: function(){ toString: function(){
return `core.queuedAction('${name}',\n\t${ return `core.queuedAction('${name}',\n\t${
@ -2683,8 +2688,9 @@ function(name, func){
&& args.pop() && args.pop()
var [name, opts] = args var [name, opts] = args
var action
return object.mixin( return object.mixin(
Queued(function(items, ...args){ action = Queued(function(items, ...args){
var that = this var that = this
// sync start... // sync start...
if(arguments[0] == 'sync'){ if(arguments[0] == 'sync'){
@ -2715,10 +2721,12 @@ function(name, func){
{}, {},
opts || {}, opts || {},
{ {
auto_stop: true, // XXX not sure about this...
//auto_stop: true,
handler: function([item, args]){ handler: function([item, args]){
return func.call(that, item, ...(args || [])) }, return func.call(that, item, ...(args || [])) },
})) }))
q.title = action.name
// pre-process args... // pre-process args...
arg_handler arg_handler
&& ([items, ...args] = && ([items, ...args] =
@ -2780,6 +2788,7 @@ var TaskActions = actions.Actions({
this.__tasks this.__tasks
|| this.__task_manager__()) }, || this.__task_manager__()) },
// session tasks are stopped when the index is cleared... // session tasks are stopped when the index is cleared...
// XXX need to get running tasks by action name...
get sessionTasks(){ get sessionTasks(){
return this.tasks.titled(...this.sessionTaskActions) }, return this.tasks.titled(...this.sessionTaskActions) },
@ -2789,6 +2798,7 @@ var TaskActions = actions.Actions({
isQueued: function(action){ isQueued: function(action){
return !!this.getActionAttr(action, '__queued__') }, return !!this.getActionAttr(action, '__queued__') },
// XXX cache this??? // XXX cache this???
// XXX need to get running tasks by action name...
get queuedActions(){ get queuedActions(){
var test = this.isQueued.bind(this) var test = this.isQueued.bind(this)
return this.actions.filter(test) }, return this.actions.filter(test) },
@ -2867,7 +2877,7 @@ var TaskActions = actions.Actions({
// cleanup... // cleanup...
queue queue
.then( .then(
cleanup('done'), cleanup('done'),
cleanup('error')) } cleanup('error')) }
// add queue as task... // add queue as task...

View File

@ -280,14 +280,14 @@ var ExampleActions = actions.Actions({
this.exampleQueuedAction(timeout) } }], this.exampleQueuedAction(timeout) } }],
exampleQueueHandlerAction: ['- Test/', exampleQueueHandlerAction: ['- Test/',
core.queueHandler('exampleQueueHandlerAction', core.queueHandler('Example queue handler action',
{quiet: true}, {quiet: true},
function(item, ...args){ function(item, ...args){
console.log('Queue handler action!!', item, ...args) console.log('Queue handler action!!', item, ...args)
return new Promise(function(resolve){ return new Promise(function(resolve){
setTimeout(resolve, 100) }) })], setTimeout(resolve, 100) }) })],
exampleQueueHandlerActionWArgs: ['- Test/', exampleQueueHandlerActionWArgs: ['- Test/',
core.queueHandler('exampleQueueHandlerActionWArgs', core.queueHandler('Example queue handler with arguments',
{quiet: true}, {quiet: true},
function(queue, from=0, to=100, ...args){ function(queue, from=0, to=100, ...args){
var items = [] var items = []

View File

@ -1073,9 +1073,9 @@
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
}, },
"ig-actions": { "ig-actions": {
"version": "3.24.20", "version": "3.24.21",
"resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.20.tgz", "resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.21.tgz",
"integrity": "sha512-V5jOhwxjRMoNS1vT6O0nZKh9063FAxtnQoo4G/iH1Kf9jKGqDNlXY4WhoimxGdJF9cdYs+LGxLFjkjek+jaAcg==", "integrity": "sha512-fPdi3BEKxKDVcYiO9+Utg3NCqCATQUXPU+wIbdAsA4+AT8zx1EPKZl+vLUn3V0VPKAh9O4bvlWxqNn4GNjC2fQ==",
"requires": { "requires": {
"ig-object": "^5.4.12" "ig-object": "^5.4.12"
} }
@ -1110,9 +1110,9 @@
"integrity": "sha512-9kZM80Js9/eTwXN9VXwLDC1wDJ7gIAdYU9GIzb5KJmNcLAMaW+zhgFrwFFMrcSfggUuadgnqSrS41E4XLe8JZw==" "integrity": "sha512-9kZM80Js9/eTwXN9VXwLDC1wDJ7gIAdYU9GIzb5KJmNcLAMaW+zhgFrwFFMrcSfggUuadgnqSrS41E4XLe8JZw=="
}, },
"ig-types": { "ig-types": {
"version": "5.0.37", "version": "5.0.38",
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.37.tgz", "resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.38.tgz",
"integrity": "sha512-VLMCgpWTNXhNOW57WZh2jaMdcth3iRqz3DIlaezpIWaMURTsldmqIS5UMqf7EzZ5E1ZW1b/342P8ccJIUEB+cQ==", "integrity": "sha512-eiDnadPddsSlq68wulCGMl00nL8MLrwFrBhw2peioXWwvJHkS1tA4qUiYaNYZDK3tEFo1B3idx3nBQ8jiATWAA==",
"requires": { "requires": {
"ig-object": "^5.4.12", "ig-object": "^5.4.12",
"object-run": "^1.0.1" "object-run": "^1.0.1"

View File

@ -28,11 +28,11 @@
"generic-walk": "^1.4.0", "generic-walk": "^1.4.0",
"glob": "^7.1.6", "glob": "^7.1.6",
"guarantee-events": "^1.0.0", "guarantee-events": "^1.0.0",
"ig-actions": "^3.24.20", "ig-actions": "^3.24.21",
"ig-argv": "^2.15.0", "ig-argv": "^2.15.0",
"ig-features": "^3.4.2", "ig-features": "^3.4.2",
"ig-object": "^5.4.12", "ig-object": "^5.4.12",
"ig-types": "^5.0.37", "ig-types": "^5.0.38",
"moment": "^2.29.1", "moment": "^2.29.1",
"object-run": "^1.0.1", "object-run": "^1.0.1",
"requirejs": "^2.3.6", "requirejs": "^2.3.6",