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


TypeScript Observable.flatMap方法代碼示例

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


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

示例1:

  let reducer = (outputStream: Observable<Resource>, toResourceTypeExtension: string) => {
    let toResourceType = env.resourceTypes.lookup(toResourceTypeExtension);

    // Apply conversion transformations (from -> to) resource type.
    if (fromResourceType !== null) {
      let conversionTransformers = fromResourceType.conversions[toResourceTypeExtension];
      if (!!conversionTransformers) {
        outputStream = outputStream.flatMap(outputResource =>
          env.behaviors.applySequenceOfTransformsToResource(outputResource, fromResourceType, conversionTransformers)
        );
      }
    }

    // Prepare for next iteration.
    fromResourceType = toResourceType;

    // Apply process transformations for the current resource type.
    return outputStream.flatMap(outputResource =>
      env.behaviors.processResource(outputResource, toResourceType)
    );
  };
開發者ID:webreed,項目名稱:webreed-core,代碼行數:21,代碼來源:applyExtensionChainToResource.ts

示例2: ngOnInit

    public ngOnInit(): void {
        let { type, data, resetPosition }: any = this.options;
        type = type || "any";
        resetPosition = resetPosition === undefined ? true : resetPosition;

        this.dragStart
            .flatMap(e => Observable.of(e).delay(150).takeUntil(this.dragEnd))
            .map((e: any) => {
                e.preventDefault();
                this.el.classList.add("dragged");
                let { left, top }: any = this.el.style;
                let clientX: number = e.clientX || e.touches[0].clientX;
                let clientY: number = e.clientY || e.touches[0].clientY;
                return {
                    left: clientX,
                    top: clientY,
                    offsetLeft: DraggableDirective.offsetToNumber(left),
                    offsetTop: DraggableDirective.offsetToNumber(top)
                };
            })
            .flatMap((source: any) => this.dragMove
                .map((e: any) => {
                    let clientX: number = e.clientX || e.touches[0].clientX;
                    let clientY: number = e.clientY || e.touches[0].clientY;
                    this.service.dragged.next({ clientX, clientY});
                    return {
                        left: clientX - source.left + source.offsetLeft,
                        top: clientY - source.top + source.offsetTop
                    };
                })
                .takeUntil(this.dragEnd.do((e: any) => {
                    this.el.classList.remove("dragged");
                    this.service.dropped.next({ type, data });
                    if (resetPosition) {
                        this.resetPosition();
                    }
                }))
            )
            .subscribe(({ top, left }: any) => {
                this.el.style.left = left + "px";
                this.el.style.top = top + "px";
            });

    }
開發者ID:tomastrajan,項目名稱:fintech-example,代碼行數:44,代碼來源:draggable-directive.ts

示例3: process

 process(observable: Observable<any>, context?: any): Observable<any> {
     return observable.flatMap(o => this.transformer.process(o, context));
 }
開發者ID:smartive,項目名稱:proc-that,代碼行數:3,代碼來源:MapTransformer.ts


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