mirror of
https://github.com/flynx/types.js.git
synced 2025-12-19 09:51:40 +00:00
added basic error handling...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
0979eab329
commit
cb1f2d95b8
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-types",
|
||||
"version": "5.0.5",
|
||||
"version": "5.0.6",
|
||||
"description": "Generic JavaScript types and type extensions...",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
18
runner.js
18
runner.js
@ -369,7 +369,9 @@ object.Constructor('TaskManager', Array, events.EventMixin('flat', {
|
||||
this.named(name).stop()
|
||||
: this.forEach(function(task){
|
||||
task.stop() }) }),
|
||||
|
||||
done: events.Event('done'),
|
||||
error: events.Event('error'),
|
||||
|
||||
|
||||
//
|
||||
@ -405,6 +407,9 @@ object.Constructor('TaskManager', Array, events.EventMixin('flat', {
|
||||
: task instanceof Promise ?
|
||||
Promise.interactive(
|
||||
function(resolve, reject, onmsg){
|
||||
onmsg(function(msg){
|
||||
msg == 'stop'
|
||||
&& reject() })
|
||||
task.then(resolve, reject) })
|
||||
// function...
|
||||
: Promise.interactive(
|
||||
@ -426,9 +431,16 @@ object.Constructor('TaskManager', Array, events.EventMixin('flat', {
|
||||
|
||||
// handle done...
|
||||
handler
|
||||
.then(function(res){
|
||||
that.splice(that.indexOf(handler), 1)
|
||||
that.trigger('done', task, res)
|
||||
.then(
|
||||
function(res){
|
||||
that.splice(that.indexOf(handler), 1)
|
||||
that.trigger('done', task, res) },
|
||||
// err...
|
||||
function(res){
|
||||
that.splice(that.indexOf(handler), 1)
|
||||
that.trigger('error', task, res) })
|
||||
handler
|
||||
.finally(function(){
|
||||
that.length == 0
|
||||
&& that.done('all') })
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user