Skip to content

Commit 6ceba1b

Browse files
committed
add event 'Fail'
1 parent 800a51a commit 6ceba1b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/js-multi-data-module.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export default class MULTI_DATA_MODULE {
4040
}
4141
this.On = {
4242
Update : options.on.Update||'',
43-
Complete : options.on.Complete||''
43+
Complete : options.on.Complete||'',
44+
Fail : options.on.Fail||''
4445
};
4546

4647
// For Jsonp data.
@@ -126,7 +127,7 @@ export default class MULTI_DATA_MODULE {
126127
})
127128
.catch((err)=>{
128129
// Error.
129-
console.log('%c'+err,'color: red');
130+
this.OnFail({message: err, data: this.DataList[count]});
130131

131132
this.DataFix = this.DataFix.concat(['']);
132133
this.DataList[count] = [];
@@ -223,7 +224,7 @@ export default class MULTI_DATA_MODULE {
223224
})
224225
.catch((err)=>{
225226
// Error.
226-
console.log('%c'+err,'color: red');
227+
this.OnFail({message: err, data: this.DataList[count]});
227228

228229
this.DataFix = this.DataFix.concat(['']);
229230
this.DataList[count] = [];
@@ -333,7 +334,7 @@ export default class MULTI_DATA_MODULE {
333334
})
334335
.catch((err)=>{
335336
// Error.
336-
console.log('%c'+err,'color: red');
337+
this.OnFail({message: err, data: this.DataList[count]});
337338

338339
this.DataFix = this.DataFix.concat(['']);
339340
this.DataList[count] = [];
@@ -417,4 +418,11 @@ export default class MULTI_DATA_MODULE {
417418
}
418419
}
419420

421+
OnFail(e={}){
422+
// Callback function.
423+
if(this.On.Fail && typeof(this.On.Fail) === 'function'){
424+
this.On.Fail(e);
425+
}
426+
}
427+
420428
}

0 commit comments

Comments
 (0)