2015-03-17 22:12:19 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import _ from '_';
|
|
|
|
import Promise from 'Promise';
|
|
|
|
import {isArray} from 'Common/Utils';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
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;
|
|
|
|
_.each(isArray(trigger) ? trigger : [trigger], (fTrigger) => {
|
|
|
|
if (fTrigger)
|
|
|
|
{
|
|
|
|
fTrigger(value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-03-17 22:12:19 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2015-03-17 22:12:19 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
export {AbstractBasicPromises, AbstractBasicPromises as default};
|