snappymail/dev/Promises/AbstractBasic.js

30 lines
470 B
JavaScript
Raw Normal View History

import window from 'window';
2016-06-30 08:02:45 +08:00
2019-07-05 03:19:24 +08:00
export class AbstractBasicPromises {
2016-09-10 06:38:16 +08:00
oPromisesStack = {};
2016-06-30 08:02:45 +08:00
func(fFunc) {
fFunc();
return this;
}
2016-06-30 08:02:45 +08:00
fastResolve(mData) {
return window.Promise.resolve(mData);
}
2016-06-30 08:02:45 +08:00
fastReject(mData) {
return window.Promise.reject(mData);
}
2016-06-30 08:02:45 +08:00
setTrigger(trigger, value) {
2019-07-05 03:19:24 +08:00
if (trigger) {
value = !!value;
(Array.isArray(trigger) ? trigger : [trigger]).forEach((fTrigger) => {
2019-07-05 03:19:24 +08:00
if (fTrigger) {
fTrigger(value);
}
});
}
}
}