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