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


TypeScript Observable.combineLatest方法代碼示例

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


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

示例1: asObservable

 asObservable(): Observable<MessageSetting> {
     return Observable.combineLatest(
         this._showJoin.asObservable(),
         this._showPart.asObservable(),
         this._showMode.asObservable(),
         this._showMotd.asObservable(),
         this._showNickChange.asObservable(),
         this._showQuit.asObservable(),
         (showJoin, showPart, showMode, showMotd, showNickChange, showQuit) => {
             return {
                 showJoin,
                 showPart,
                 showMode,
                 showMotd,
                 showNickChange,
                 showQuit,
             };
         }
     );
 }
開發者ID:karen-irc,項目名稱:karen,代碼行數:20,代碼來源:GeneralSettingViewModel.ts

示例2:

 .mergeMap(l => {
     const vendors: Observable<{ item: any, vendors: Vendor[] }>[] = [];
     this.forEachItem(list, item => {
         const related = this.getRelated(data, item.id);
         if (related !== undefined && related.vendors !== undefined) {
             vendors.push(this.getVendors(related).map(ts => {
                 return {item: item, vendors: ts};
             }));
         }
     });
     if (vendors.length > 0) {
         return Observable.combineLatest(...vendors, (...pvendors) => {
             pvendors.forEach(v => {
                 v.item.vendors = v.vendors;
             });
             return l;
         });
     } else {
         return Observable.of(l);
     }
 })
開發者ID:aluink,項目名稱:ffxiv-teamcraft,代碼行數:21,代碼來源:list-manager.service.ts

示例3: it

 it('should make multiple user event Observables', function (done) {
   const userEvents = mockDOMSource({
     '.foo': {
       'click': Observable.of(135),
     },
     '.bar': {
       'scroll': Observable.of(2),
     },
   });
   Observable.combineLatest(
     userEvents.select('.foo').events('click'),
     userEvents.select('.bar').events('scroll'),
     (a: number, b: number) => a * b,
   ).subscribe({
     next: ev => {
       assert.strictEqual(ev, 270);
       done();
     },
     error: err => done(err),
     complete: () => {},
   });
 });
開發者ID:whitecolor,項目名稱:cyclejs,代碼行數:22,代碼來源:mock-dom-source.ts

示例4: ngOnInit

  ngOnInit() {
    
    let filterTodos = (val: boolean) => (item: Todo) => item.completed === val;

    this.hideCompleted$ = this.ngRedux.select(state => {
      
      return !state.filter.showCompleted;
    });

    this.todos$ = this.ngRedux
      .select(n => n.todos);

    this.completedTodos$ = this.todos$
      .map(todos => todos.filter(filterTodos(true)));

    this.incompleteTodos$ = this.todos$
      .map(todos => todos.filter(filterTodos(false)));

    this.total$ = this.todos$.pluck('length');
    this.completed$ = this.completedTodos$.pluck('length');

    this.filteredTodos$ = this.todos$
      .combineLatest(this.hideCompleted$, (todos, filter) => {
        return todos.filter(n => filterTodos(false)(n) || filter === false);
      });

    this.ngRedux.mapDispatchToTarget({
      completeTodo,
      editTodo,
      deleteTodo,
      filterCompleted,
      completeAll,
      clearCompleted,
      addTodo
    })(this);

  }
開發者ID:e-schultz,項目名稱:angular2-redux-example,代碼行數:37,代碼來源:todo-page.ts

示例5: constructor

  constructor(router: Router, zone: NgZone) {
    if (typeof prebootstrap === 'undefined') {
      return;
    }

    const finished = Observable.combineLatest(router.events, zone.onMicrotaskEmpty);

    const subscription = finished.subscribe(([event, stable]) => {
      if (stable === false) {
        return;
      }

      switch (true) {
        case event instanceof NavigationError:
        case event instanceof NavigationEnd:
          setImmediate(() => prebootClient().complete());

          subscription.unsubscribe();
          break;
        default:
          break;
      }
    });
  }
開發者ID:sonukapoor,項目名稱:angular-ssr,代碼行數:24,代碼來源:root.module.ts

示例6:

export const constructedPlaylistItem = (store: any) => Observable
    .combineLatest(store.let(playlistSelector),
                   store.let(artistSelector),
                   store.let(audioSelector),
                   store.let(playlistArraySelector))
    .map((res: any) => {
        console.log("[playlist.selector] --constructedPlaylistItem- playlistArraySelector --res[0] ", res[0]);
         // console.log("[playlist.selector] --constructedPlaylistItem- artistSelector --res[1] ", res[1]);
         // console.log("[playlist.selector] --constructedPlaylistItem- audioSelector --res[2] ", res[2]);

        var playlist =  Object.assign({}, res[0]);
        console.log("[playlist.selector] --constructedPlaylistItem- playlistArraySelector --res[0].length "+ res[0].length);
        console.log("[playlist.selector] --constructedPlaylistItem- playlistArraySelector --playlist.audioList.length = "+ playlist.audioList.length);

        if(playlist.audioList.length>0 ){
            var artistAudioItem =  Object.keys(res[1]) .filter( x =>  {
                                      return res[1][x].id  ===  res[2].artistId})
                                     .map(x => {return res[1][x]})[0];

            var newResult = Object.keys(playlist.audioList).map(key => ({key:key, playlistItem:playlist.audioList[key]})).map( value =>{
              // obj = res[0][value.key];
              console.log("playlist.selector] --constructedPlaylistItem --value ",value);
               console.log("playlist.selector] --constructedPlaylistItem --value.playlistItem.artistId", value.playlistItem.artistId);
             // console.log("playlist.selector] --constructedPlaylistItem --artistAudioItem.id", artistAudioItem.id);
               if(value.playlistItem.artistId === artistAudioItem.id){
                  playlist.audioList[value.key] =  Object.assign({}, value.playlistItem, {artist:artistAudioItem} );
                  //console.log("playlist.selector] --constructedPlaylistItem --   playList[value.key] =",  playList[value.key]);
               }
            });
            console.log("playlist.selector] --constructedPlaylistItem --valueer --playlist.audioList ", playlist.audioList);
            return playlist.audioList;
        }else{
        console.log("[playlist.selector] -- constructedPlaylistItem -- DEFAULT");
           return res[3];
        }
    });
開發者ID:willSonic,項目名稱:angular2-exp-ngrx,代碼行數:36,代碼來源:playlist.selector.ts


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