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

View File

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

View File

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

View File

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