2017-06-25 03:26:27 +08:00
|
|
|
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
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
func(fFunc) {
|
|
|
|
fFunc();
|
|
|
|
return this;
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
fastResolve(mData) {
|
2017-06-25 03:26:27 +08:00
|
|
|
return window.Promise.resolve(mData);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
fastReject(mData) {
|
2017-06-25 03:26:27 +08:00
|
|
|
return window.Promise.reject(mData);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
setTrigger(trigger, value) {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (trigger) {
|
2016-08-17 06:01:20 +08:00
|
|
|
value = !!value;
|
2020-07-30 03:49:41 +08:00
|
|
|
(Array.isArray(trigger) ? trigger : [trigger]).forEach((fTrigger) => {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (fTrigger) {
|
2016-08-17 06:01:20 +08:00
|
|
|
fTrigger(value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-03-17 22:12:19 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|