当前位置: 首页>>代码示例>>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;未经允许,请勿转载。