当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Observable.merge方法代码示例

本文整理汇总了TypeScript中rxjs/Rx.Observable.merge方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable.merge方法的具体用法?TypeScript Observable.merge怎么用?TypeScript Observable.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rxjs/Rx.Observable的用法示例。


在下文中一共展示了Observable.merge方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: todoItemDataFlow

export function todoItemDataFlow(intent: TodoItemIntent, todoProperty$: Observable<Todo>){
    const editing$ = Observable.merge<boolean, boolean>(
        intent.startEdit$.map(() => true),
        intent.stopEdit$.map(() => false),
        intent.cancelEdit$.map(() => false)
    ).startWith(false);

    const viewModel$ = todoProperty$
        .combineLatest(editing$, (todoProperty, editing) => Object.assign({}, todoProperty, { editing }));

    const delete$ = intent.delete$
        .withLatestFrom(todoProperty$, (_, todo: Todo) => todo)
        .map(x => ({ id: x.id }));

    const edit$ = intent.stopEdit$
        .withLatestFrom(todoProperty$, (title: string, todo: Todo) => ({ title, todo }))
        .filter(x => x.title !== x.todo.title)
        .map(x => ({ id: x.todo.id, title: x.title }));

    const toggle$ = intent.toggleTodo$
        .withLatestFrom(todoProperty$, (_, todo: Todo) => todo)
        .map(todo => ({ id: todo.id }));

    return {
        viewModel$,
        delete$,
        edit$,
        toggle$
    };
}
开发者ID:Avisy,项目名称:todomvc-ng2-reactive,代码行数:30,代码来源:todo-item.data-flow.ts

示例2:

 // 全てのStoreのStateUpdateをComponentに通知する。
 // Componentはこのストリームを受けてcd.markForCheck()すればOnPush環境でViewを動的に更新できる。  
 get storeNotificator$$() {
   // return this.mainStore.takeLatest$(_NOTIFICATION_); 
   const observables = this.stores.map(store => store.takeLatest$<any>(_NOTIFICATION_));
   return Observable
     .merge(...observables);
   // .debounceTime(10); // あまり細かくストリームを流す必要もないのでdebounceTime
 }
开发者ID:ovrmrw,项目名称:shuttle-store-sample,代码行数:9,代码来源:store.controller.ts

示例3: getEvent

  /**
   *
   * @param eventId string
   * Get event informations
   */
  getEvent(eventId): Observable<any> {
    const cacheKey: string = 'event_' + eventId;

    let cacheStream = this.cache.getCache(cacheKey);

    let webStream = this.storage.getValue('id').switchMap(id => {
      return this.http.get(this.baseUrl + '/chillers/' + id + '/events/' + eventId)
        .map(res => res.json())
        .filter(res => res)
        .map(res => {
          if (res.chillerid == id) {
            res.mine = true;
          } else {
            res.mine = false;
          }

          return res;
        })
        .map(res => {
          this.cache.setCache(cacheKey, res);

          return res;
        });
    });

    return Observable.merge(cacheStream, webStream)
      .filter(res => res);
  }
开发者ID:ColinJS,项目名称:Chillter,代码行数:33,代码来源:api.ts

示例4:

    select<T extends Component, T2 extends Component>(v1: Type<T>, v2: Type<T2>): Rx.Observable<[T,T2]> {
    let r1 = Rx.Observable.of(...this.state.getComponentMap(v1).values());
    let r2 = Rx.Observable.of(...this.state.getComponentMap(v2).values());

    return Rx.Observable
      .merge<T,T2>(r1, r2)
      .groupBy(c => c.entityId)
      .flatMap(group => group.reduce((acc, curr) => [...acc, curr], []))
      .filter(a => a.length === 2);
  }
开发者ID:hokkaido,项目名称:moss,代码行数:10,代码来源:store.ts

示例5:

 .flatMap(i => {
     let j1 = Observable.create(s => {
         $.get("http://localhost:8080/double?number=" + (i), d => s.next(d));
     });
     let j2 = Observable.create(s => {
         $.get("http://localhost:8080/double?number=" + (i + 100), d => s.next(d));
     });
     let j3 = Observable.create(s => {
         $.get("http://localhost:8080/double?number=" + (i + 1000000), d => s.next(d));
     });
     return Observable.merge(j1, j2, j3);
 })
开发者ID:romanroe,项目名称:angular2-rx-demo,代码行数:12,代码来源:intro.ts

示例6: fromDictionary

  selects<T extends Component, T2 extends Component>(v1: Type<T>, v2: Type<T2>): Rx.Observable<[T,T2]> {
    let r1 = fromDictionary(this.state.getComponentMap(v1));
    let r2 = fromDictionary(this.state.getComponentMap(v2));

    return Rx.Observable
      .merge<T,T2>(r1, r2)
      .groupBy(c => c.entityId)
      .flatMap(group => group.reduce((acc, curr) => [...acc, curr], []))
      .filter(arr => arr.length === 2)
      .map(arr => {
        return [arr[0], arr[1]]
      })
  }
开发者ID:hokkaido,项目名称:moss,代码行数:13,代码来源:store.ts

示例7: createExecuteTradeResponse

 .subscribe(limitCheckResult => {
   if (limitCheckResult) {
     const request = serviceClient
       .createRequestResponseOperation(
         'executeTrade',
         executeTradeRequest
       )
       .publish()
       .refCount()
     disposables.add(
       Observable.merge(
         request
           .map(dto => {
             const trade = tradeMapper.mapFromTradeDto(dto.Trade)
             log.info(
               `execute response received for: ${executeTradeRequest}. Status: ${trade.status}`,
               dto
             )
             return createExecuteTradeResponse(trade)
           })
           // if we never receive a response, mark request as complete
           .timeout(
             EXECUTION_REQUEST_TIMEOUT_MS,
             Scheduler.asap.schedule(() =>
               createExecuteTradeResponseForError(
                 'Trade execution timeout exceeded',
                 executeTradeRequest
               )
             )
           ),
         // show timeout error if request is taking longer than expected
         Observable.timer(EXECUTION_CLIENT_TIMEOUT_MS)
           .map(() =>
             createExecuteTradeResponseForError(
               'Trade execution timeout exceeded',
               executeTradeRequest
             )
           )
           .takeUntil(request)
       ).subscribe(o)
     )
   } else {
     o.next(
       createExecuteTradeResponseForError(
         'Credit limit exceeded',
         executeTradeRequest
       )
     )
   }
 })
开发者ID:carlosrfernandez,项目名称:ReactiveTraderCloud,代码行数:50,代码来源:executionService.ts

示例8: getProfileId

  /**
   *
   * Return the profile id: number
   */
  getProfileId(): Observable<any> {
    let id = this.storage.getValue('id')
      .filter(id => id)
      .switchMap(id => {
        return this.http.get(this.baseUrl + '/chillers/' + id)
          .map(res => res.json())
          .filter(res => res)
          .map(res => {
            return id;
          });
      }
      );

    return Observable.merge(id)
      .filter(res => res);
  }
开发者ID:ColinJS,项目名称:Chillter,代码行数:20,代码来源:api.ts

示例9: jQuery

 jQuery.getJSON(url, ()=> {
     var path = `https://${source}/Snapshots/business${businessId}/station${stationId}/${fileName}.jpg`;
     jQuery(this.elRef.nativeElement).find('.newImage').fadeOut(200);
     var img = this.renderer.createElement(this.elRef.nativeElement, 'img', null);
     jQuery(img).addClass('snap');
     var int$ = Observable.interval(500).do(()=> {
         img.src = path;
     })
     var $err = Observable.fromEvent(img, 'error').do(()=>{
         jQuery(this.elRef.nativeElement).find('.snap').remove();
     })
     var load$ = Observable.fromEvent(img, 'load')
     var subscription = Observable.merge(int$, $err).takeUntil(load$).delay(500).subscribe((res)=> {
         subscription.unsubscribe();
     })
 });
开发者ID:amurarnd,项目名称:studioDashboard,代码行数:16,代码来源:StationSnapshot.ts

示例10: getChill

  /**
   *
   * @param id string
   * Get chill information when editing
   */
  getChill(id): Observable<any> {
    const cacheKey: string = 'chill_' + id;

    let cacheStream = this.cache.getCache(cacheKey);

    let webStream = this.http.get(this.baseUrl + '/chills/' + id)
      .map(res => res.json())
      .filter(res => res)
      .map(res => {
        this.cache.setCache(cacheKey, res);

        return res;
      });

    return Observable.merge(cacheStream, webStream)
      .filter(res => res);
  }
开发者ID:ColinJS,项目名称:Chillter,代码行数:22,代码来源:api.ts


注:本文中的rxjs/Rx.Observable.merge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。