snappymail/dev/Promises/AbstractBasic.js

38 lines
574 B
JavaScript
Raw Normal View History

import _ from '_';
import Promise from 'Promise';
import {isArray} from 'Common/Utils';
2016-06-30 08:02:45 +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
func(fFunc) {
fFunc();
return this;
}
2016-06-30 08:02:45 +08:00
fastResolve(mData) {
return Promise.resolve(mData);
}
2016-06-30 08:02:45 +08:00
fastReject(mData) {
return Promise.reject(mData);
}
2016-06-30 08:02:45 +08:00
setTrigger(trigger, value) {
if (trigger)
{
value = !!value;
_.each(isArray(trigger) ? trigger : [trigger], (fTrigger) => {
if (fTrigger)
{
fTrigger(value);
}
});
}
}
}
export {AbstractBasicPromises, AbstractBasicPromises as default};