當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Q.defer函數代碼示例

本文整理匯總了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;
    }
開發者ID:bilalyasar,項目名稱:hazelcast-nodejs-client,代碼行數:8,代碼來源:PartitionService.ts

示例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; 
 }
開發者ID:dsilva2401,項目名稱:server-seed,代碼行數:8,代碼來源:Person.ts

示例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;
 }
開發者ID:dsilva2401,項目名稱:server-seed,代碼行數:8,代碼來源:Person.ts

示例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;
 }
開發者ID:HelloMQL,項目名稱:protractor,代碼行數:17,代碼來源:local.ts

示例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;
}
開發者ID:micurs,項目名稱:relaxjs,代碼行數:8,代碼來源:internals.ts

示例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');
 });
開發者ID:cboggs,項目名稱:grafana,代碼行數:8,代碼來源:history_ctrl.jest.ts

示例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;
			}
開發者ID:dsilva2401,項目名稱:server-seed,代碼行數:8,代碼來源:Credential.ts

示例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
}
開發者ID:pushrocks,項目名稱:plr,代碼行數:8,代碼來源:mod.browser.ts

示例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;
			}
開發者ID:dsilva2401,項目名稱:server-seed,代碼行數:8,代碼來源:LoginController.ts

示例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);
 }
開發者ID:DylanLacey,項目名稱:protractor,代碼行數:13,代碼來源:useExistingWebDriver.ts


注:本文中的Q.defer函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。