2015-03-17 22:12:19 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import Promise from 'Promise';
|
|
|
|
import {isArray} from 'Common/Utils';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-10-19 01:52:43 +08:00
|
|
|
export class AbstractBasicPromises
|
2016-06-30 08:02:45 +08:00
|
|
|
{
|
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) {
|
|
|
|
return Promise.resolve(mData);
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
fastReject(mData) {
|
|
|
|
return Promise.reject(mData);
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
setTrigger(trigger, value) {
|
|
|
|
if (trigger)
|
|
|
|
{
|
|
|
|
value = !!value;
|
2016-10-19 01:52:43 +08:00
|
|
|
(isArray(trigger) ? trigger : [trigger]).forEach((fTrigger) => {
|
2016-08-17 06:01:20 +08:00
|
|
|
if (fTrigger)
|
|
|
|
{
|
|
|
|
fTrigger(value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-03-17 22:12:19 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|