made the task protocol a bit more flexible -- fixed queue interaction...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-12-03 17:53:25 +03:00
parent 6d5d56b510
commit d18823c6a5
2 changed files with 14 additions and 3 deletions

View File

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

View File

@ -638,10 +638,20 @@ object.Constructor('TaskManager', Array, events.EventMixin('flat', {
// actions...
//
// commands to test as methods...
// i.e. task.send(cmd, ...args) -> task[cmd](...args)
__send_commands__: [ 'stop' ],
send: function(title, ...args){
var that = this
if(title == 'all' || title == '*'){
this.forEach(function(task){
task.send(...args) })
'send' in task ?
task.send(...args)
: that.__send_commands__.includes(args[0]) ?
task[args[0]](...args.slice(1))
// XXX
: console.warn('.send(..): can\'t .send(..) to:', task)
})
return this }
return this.titled(
...(title instanceof Array) ?
@ -747,7 +757,8 @@ object.Constructor('TaskManager', Array, events.EventMixin('flat', {
task instanceof Queue ?
task
// task protocol...
: task && task.then && task.stop ?
: task && task.then
&& (task.stop || task.send) ?
task
: this.__task_mixin__(
// interactive promise...