本文整理匯總了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);
}