2015-03-17 22:12:19 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
var
|
|
|
|
_ = require('_'),
|
|
|
|
Promise = require('Promise'),
|
|
|
|
|
|
|
|
Utils = require('Common/Utils');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function AbstractBasicPromises()
|
|
|
|
{
|
|
|
|
this.oPromisesStack = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
AbstractBasicPromises.prototype.func = function(fFunc)
|
|
|
|
{
|
|
|
|
fFunc();
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
|
|
|
AbstractBasicPromises.prototype.fastResolve = function(mData)
|
|
|
|
{
|
|
|
|
return Promise.resolve(mData);
|
|
|
|
};
|
|
|
|
|
|
|
|
AbstractBasicPromises.prototype.fastReject = function(mData)
|
|
|
|
{
|
|
|
|
return Promise.reject(mData);
|
|
|
|
};
|
|
|
|
|
|
|
|
AbstractBasicPromises.prototype.setTrigger = function(mTrigger, bValue)
|
|
|
|
{
|
|
|
|
if (mTrigger)
|
2015-03-17 22:12:19 +08:00
|
|
|
{
|
2016-06-30 08:02:45 +08:00
|
|
|
_.each(Utils.isArray(mTrigger) ? mTrigger : [mTrigger], function(fTrigger) {
|
|
|
|
if (fTrigger)
|
|
|
|
{
|
|
|
|
fTrigger(!!bValue);
|
|
|
|
}
|
|
|
|
});
|
2015-03-17 22:12:19 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
};
|
2015-03-17 22:12:19 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
module.exports = AbstractBasicPromises;
|