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


TypeScript Observable.empty方法代碼示例

本文整理匯總了TypeScript中rxjs.Observable.empty方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable.empty方法的具體用法?TypeScript Observable.empty怎麽用?TypeScript Observable.empty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rxjs.Observable的用法示例。


在下文中一共展示了Observable.empty方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: type

 type('should return T for ObservableLike objects', () => {
   /* tslint:disable:no-unused-variable */
   const o1: Observable<number> = from([] as number[], asapScheduler);
   const o2: Observable<{ a: string }> = from(Observable.empty());
   const o3: Observable<{ b: number }> = from(new Promise<{b: number}>(resolve => resolve()));
   /* tslint:enable:no-unused-variable */
 });
開發者ID:jayphelps,項目名稱:rxjs,代碼行數:7,代碼來源:from-spec.ts

示例2: newgameReducer

 .map(action => function newgameReducer(state) {
   return {
     past: state.past.concat(state.present),
     present: O.empty(),
     future: []
   };
 }),
開發者ID:wizardwerdna,項目名稱:FRPBowlingKata,代碼行數:7,代碼來源:model.ts

示例3: showNotification

    showNotification(channelId: ChannelId, from: string, text: string): void {
        const settings = this._config.get();
        if (settings.notification) {
            // FIXME: should call in `NotificationActionCreator.showNotification()`
            this._notifyAction.playSound();
        }

        if (settings.badge && Notification.permission === 'granted') {
            let notification = new Notification(from + ' says:', {
                body: text,
                icon: ICON_URL,
            });

            const timeout: Rx.Observable<void> = Rx.Observable.empty<void>().delay(5 * 1000);
            const click: Rx.Observable<void> = Rx.Observable.fromEvent<void>(notification, 'click').take(1).do<void>(() => {
                this._uiAction.focusWindow();
                this._uiAction.selectChannel(channelId);
            });

            const close: Rx.Observable<void> = click.race(timeout);
            close.subscribe(function(){}, function(){}, function(){
                notification.close();
                notification = null;
            });
        }
    }
開發者ID:karen-irc,項目名稱:karen,代碼行數:26,代碼來源:NotificationPresenter.ts

示例4:

 return observable.catch((err, source) => {
   if (err.status == 401) {
     //this._router.navigate(['/login']);
     return Observable.empty();
   } else {
     return Observable.throw(err);
   }
 });
開發者ID:antoniolopesgomes,項目名稱:angular-data,代碼行數:8,代碼來源:adapter.ts

示例5:

         return observable.catch((err, source) => {
             if( err.status == 401 ) {
                 // Do something about error
                 return Observable.empty();
             }
 
             return Observable.throw(err);
         });
開發者ID:pratbhoir,項目名稱:temp,代碼行數:8,代碼來源:http.service.ts

示例6: child

 .map(i => {
   if (i % 2 === 1) {
     return child(_sources, i);
   } else {
     return {
       HTTP: Rx.Observable.empty(),
       DOM: Rx.Observable.of(''),
     };
   }
 })
開發者ID:ntilwalli,項目名稱:cyclejs,代碼行數:10,代碼來源:index.ts

示例7:

 return observable.catch((err, source) => {
     if ((err.status  == 401 || err.status  == 403) && !_.includes(err.url, 'app/auth/login') && !_.includes(err.url, 'app/auth/activate/by/key')) {
         localStorage.removeItem('user_id');
         localStorage.removeItem('name');
         this.router.navigate(['']);
         return Observable.empty();
     } else {
         return Observable.throw(err);
     }
 });
開發者ID:pozitivity,項目名稱:demo,代碼行數:10,代碼來源:custom-http.service.ts

示例8:

 return super.get(url, options).catch((err, caught) => {
   if (err.status === 401
     // && !_.endsWith(err.url, 'api/auth/login')
   ) {
     // this._router.navigate(['/login']);
     return Observable.empty();
   } else {
     return Observable.throw(err);
   }
 });
開發者ID:achristoph,項目名稱:angular2-starter,代碼行數:10,代碼來源:custom-http.ts

示例9: test

 test('expect(stream-of-value).toBeStreamOf(value)', function() {
   expect(Observable.empty()).toBeStreamOf(0);
   expect(Observable.of(0)).toBeStreamOf(0);
   expect(Observable.of(undefined)).toBeStreamOf(undefined);
   expect(Observable.of('here')).toBeStreamOf('here');
   expect(Observable.of(false)).toBeStreamOf(false);
   expect(Observable.of(NaN)).not.toBeStreamOf(NaN);
   expect(Observable.of(undefined)).not.toBeStreamOf(NaN);
   expect(Observable.of('here')).not.toBeStreamOf(NaN);
   expect(Observable.of(false)).not.toBeStreamOf(true);
 });
開發者ID:wizardwerdna,項目名稱:CycleSimpleFormExample,代碼行數:11,代碼來源:testsuite.spec.ts

示例10: test

 test('NO ACTION, CR, but having only white space', function() {
   const DOM = mockDOMSource(RxJSAdapter, {
     'input.name': {
       'keydown': O.of({
         keyCode: 13,
         target: {value: '  '}
       })
     }
   });
   expect(intent(DOM, O.empty()).isEmpty()).toBeStreamOf(true);
 });
開發者ID:wizardwerdna,項目名稱:FRPBowlingKata,代碼行數:11,代碼來源:intent.spec.ts


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