本文整理汇总了TypeScript中Q.defer函数的典型用法代码示例。如果您正苦于以下问题:TypeScript defer函数的具体用法?TypeScript defer怎么用?TypeScript defer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了defer函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: initialize
initialize(): Q.Promise<PartitionService> {
var deferred = Q.defer<PartitionService>();
this.refresh().then(() => {
deferred.resolve(this);
});
return deferred.promise;
}
示例2: updateOrCreatePerson
export function updateOrCreatePerson (personData: PersonModel): Promise<any> {
var model = new MongoModel('person');
var deferred = Q.defer();
model.updateOrCreate({email: personData.email}, personData).then(function () {
deferred.resolve();
}).catch(deferred.reject);
return deferred.promise;
}
示例3: getPersonDataFromEmail
export function getPersonDataFromEmail (email: string): Promise<IPerson> {
var model = new MongoModel('person');
var deferred = Q.defer();
model.findOne({ email: email }).then(function (personData?: PersonModel) {
deferred.resolve(personData);
}).catch(deferred.reject);
return deferred.promise;
}
示例4: teardownEnv
/**
* Teardown and destroy the environment and do any associated cleanup.
* Shuts down the drivers and server.
*
* @public
* @override
* @return {q.promise} A promise which will resolve when the environment
* is down.
*/
teardownEnv(): q.Promise<any> {
let deferred = q.defer();
super.teardownEnv().then(() => {
logger.info('Shutting down selenium standalone server.');
this.server_.stop().then(() => { deferred.resolve(); });
});
return deferred.promise;
}
示例5: promiseError
export function promiseError( msg: string, resName : string, errcode: number = 500 ) : Q.Promise< relaxjs.Embodiment > {
var later = Q.defer< relaxjs.Embodiment >();
_.defer( () => {
_log.error(msg);
later.reject( emitError( msg, resName, errcode ) )
});
return later.promise;
}
示例6: beforeEach
beforeEach(async () => {
deferred = $q.defer({});
historySrv.calculateDiff = jest.fn(() => deferred.promise);
deferred.resolve(compare('json'));
historyListCtrl.revisions[1].checked = true;
historyListCtrl.revisions[3].checked = true;
await historyListCtrl.getDiff('json');
});
示例7: getOwner
public getOwner (): Promise<PersonBE> {
var deferred = Q.defer();
getOwnerDataFromCredentials(this.email, this.password).then(function (personData: IPerson) {
if (!personData) deferred.resolve();
else deferred.resolve(new PersonBE(personData));
}).catch(deferred.reject);
return deferred.promise;
}
示例8:
export let run = (configArg: IPlrConfig) => {
let done = q.defer<IPlrConfig>()
smartbrowserInst = new plugins.smartbrowser.Smartbrowser({
webroot: paths.cwd,
watchFiles: [plugins.path.join(paths.cwd, '**/*')]
})
return done.promise
}
示例9: searchPerson
searchPerson (email: string, password: string): Promise<PersonBE> {
let deferred = Q.defer();
let credential = new Credential(email, password);
credential.getOwner().then(function (owner?: PersonBE) {
deferred.resolve(owner);
}).catch(this.sendError);
return deferred.promise;
}
示例10: setupDriverEnv
/**
* Configure and launch (if applicable) the object's environment.
* @return {q.promise} A promise which will resolve when the environment is
* ready to test.
*/
protected setupDriverEnv(): q.Promise<any> {
const defer = q.defer();
this.config_.seleniumWebDriver.getSession().then((session) => {
logger.info('Using session id - ' + session.getId());
return defer.resolve();
});
return q(undefined);
}