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


TypeScript merge.merge函数代码示例

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


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

示例1: ngOnInit

  ngOnInit() {
    // Setup logger
    if (environment.production) {
      Logger.enableProductionMode();
    }

    log.debug('init');

    // Setup translations
    this.i18nService.init(environment.defaultLanguage, environment.supportedLanguages);

    const onNavigationEnd = this.router.events.pipe(filter(event => event instanceof NavigationEnd));

    // Change page title on navigation or language change, based on route data
    merge(this.translateService.onLangChange, onNavigationEnd)
      .pipe(
        map(() => {
          let route = this.activatedRoute;
          while (route.firstChild) {
            route = route.firstChild;
          }
          return route;
        }),
        filter(route => route.outlet === 'primary'),
        mergeMap(route => route.data)
      )
      .subscribe(event => {
        const title = event['title'];
        if (title) {
          this.titleService.setTitle(this.translateService.instant(title));
        }
      });
  }
开发者ID:kittycash,项目名称:marketplace,代码行数:33,代码来源:app.component.ts

示例2: constructor

 constructor(private sanitizer: DomSanitizer, private orientation: ScreenOrientation) {
   this.fullscreen = merge(
     fromEvent(document, 'fullscreenchange'),
     fromEvent(document, 'webkitfullscreenchange'),
     fromEvent(document, 'mozfullscreenchange'),
   );
 }
开发者ID:ifiske,项目名称:iFiske,代码行数:7,代码来源:youtube.ts

示例3: mergeEffects

export function mergeEffects(
  sourceInstance: any
): Observable<EffectNotification> {
  const sourceName = getSourceForInstance(sourceInstance).constructor.name;

  const observables: Observable<any>[] = getSourceMetadata(
    sourceInstance
  ).map(({ propertyName, dispatch }): Observable<EffectNotification> => {
    const observable: Observable<any> =
      typeof sourceInstance[propertyName] === 'function'
        ? sourceInstance[propertyName]()
        : sourceInstance[propertyName];

    if (dispatch === false) {
      return ignoreElements.call(observable);
    }

    const materialized$ = materialize.call(observable);

    return map.call(
      materialized$,
      (notification: Notification<Action>): EffectNotification => ({
        effect: sourceInstance[propertyName],
        notification,
        propertyName,
        sourceName,
        sourceInstance,
      })
    );
  });

  return merge(...observables);
}
开发者ID:rjokelai,项目名称:platform,代码行数:33,代码来源:effects_resolver.ts

示例4: connect

  connect(): Observable<UserData[]> {
    const displayDataChanges = [
      this._paginator.page,
      this._sort.sortChange,
      this._peopleDatabase.dataChange
    ];
    return merge(...displayDataChanges).pipe(map(() => {
      const data = this.getSortedData();

      // Grab the page's slice of data.
      const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
      return data.splice(startIndex, this._paginator.pageSize);
    }));
  }
开发者ID:ravichandra480,项目名称:material2,代码行数:14,代码来源:person-data-source.ts

示例5: initListeners

export function initListeners(
    window: Window,
    document: Document,
    socket$: Inputs["socket$"],
    option$: Inputs["option$"]
): Observable<OutgoingSocketEvent> {
    const merged$ = merge(
        getScrollStream(window, document, socket$, option$),
        getClickStream(document, socket$, option$),
        getFormInputStream(document, socket$, option$),
        getFormTogglesStream(document, socket$, option$)
    );

    return merged$;
}
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:15,代码来源:listeners.ts

示例6: mergeEffects

export function mergeEffects(instance: any): Observable<any> {
  const observables: Observable<any>[] = getEffectsMetadata(instance).map(
    ({ propertyName, dispatch }): Observable<any> => {
      const observable = typeof instance[propertyName] === 'function' ?
        instance[propertyName]() : instance[propertyName];

      if (dispatch === false) {
        return ignoreElements.call(observable);
      }

      return observable;
    }
  );

  return merge(...observables);
}
开发者ID:christophercr,项目名称:effects,代码行数:16,代码来源:effects.ts

示例7: reloadImages

    function reloadImages(path, document): Observable<any> {

        const expando = generateUniqueString(Date.now());

        return merge(
            from([].slice.call(document.images))
                .pipe(
                    filter((img: HTMLImageElement) => pathsMatch(path, pathFromUrl(img.src)))
                    , map((img: HTMLImageElement) => {
                        const payload = {
                            target: img,
                            prop: 'src',
                            value: generateCacheBustUrl(img.src, expando),
                            pathname: getLocation(img.src).pathname
                        };
                        return propSet(payload);
                    })
                ),
            from(IMAGE_STYLES)
                .pipe(
                    mergeMap(({ selector, styleNames }) => {
                        return from(document.querySelectorAll(`[style*=${selector}]`)).pipe(
                            mergeMap((img: HTMLImageElement) => {
                                return reloadStyleImages(img.style, styleNames, path, expando);
                            })
                        )

                    })
                )
        );

        // if (document.styleSheets) {
        //     return [].slice.call(document.styleSheets)
        //         .map((styleSheet) => {
        //             return reloadStylesheetImages(styleSheet, path, expando);
        //         });
        // }
    }
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:38,代码来源:Reloader.ts

示例8: setScrollEffect

export function setScrollEffect(
    xs: Observable<IncomingPayload>,
    inputs: Inputs
) {
    {
        /**
         * Group the incoming event with window, document & scrollProportionally argument
         */
        const tupleStream$: Observable<Tuple> = xs.pipe(
            withLatestFrom<IncomingPayload, Window, Document, boolean>(
                inputs.window$,
                inputs.document$,
                inputs.option$.pipe(pluck("scrollProportionally"))
            )
        );

        /**
         * Split the stream between document scrolls and element scrolls
         */
        const [document$, element$] = partition(([event]: Tuple) => {
            return event.tagName === "document";
        })(tupleStream$);

        /**
         * Further split the element scroll between those matching in `scrollElementMapping`
         * and regular element scrolls
         */
        const [mapped$, nonMapped$] = partition(([event]: Tuple) => {
            return event.mappingIndex > -1;
        })(element$);

        return merge(
            /**
             * Main window scroll
             */
            document$.pipe(
                tap((incoming: Tuple) => {
                    const [
                        event,
                        window,
                        document,
                        scrollProportionally
                    ] = incoming;
                    const scrollSpace = getDocumentScrollSpace(document);

                    if (scrollProportionally) {
                        return window.scrollTo(
                            0,
                            scrollSpace.y * event.position.proportional
                        ); // % of y axis of scroll to px
                    }
                    return window.scrollTo(0, event.position.raw.y);
                })
            ),
            /**
             * Regular, non-mapped Element scrolls
             */
            nonMapped$.pipe(
                tap((incoming: Tuple) => {
                    const [
                        event,
                        window,
                        document,
                        scrollProportionally
                    ] = incoming;

                    const matchingElements = document.getElementsByTagName(
                        event.tagName
                    );
                    if (matchingElements && matchingElements.length) {
                        const match = matchingElements[event.index];
                        if (match) {
                            return scrollElement(
                                match,
                                scrollProportionally,
                                event
                            );
                        }
                    }
                })
            ),
            /**
             * Element scrolls given in 'scrollElementMapping'
             */
            mapped$.pipe(
                withLatestFrom(
                    inputs.option$.pipe(pluck("scrollElementMapping"))
                ),
                /**
                 * Filter the elements in the option `scrollElementMapping` so
                 * that it does not contain the element that triggered the event
                 */
                map(([incoming, scrollElementMapping]: [Tuple, string[]]) => {
                    const [event] = incoming;
                    return [
                        incoming,
                        scrollElementMapping.filter(
                            (item, index) => index !== event.mappingIndex
                        )
                    ];
//.........这里部分代码省略.........
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:101,代码来源:set-scroll.ts

示例9: share

            share()
        );
    };
}

const combinedEffectHandler$ = zip(
    effectOutputHandlers$,
    scrollRestoreHandlers$,
    (...args) => {
        return args.reduce((acc, item) => ({ ...acc, ...item }), {});
    }
);

const output$ = getStream("[socket]", inputs)(
    socketHandlers$,
    merge(inputs.socket$, outgoing$)
);

const effect$ = getStream("[effect]", inputs)(combinedEffectHandler$, output$);
const dom$ = getStream("[dom-effect]", inputs)(
    domHandlers$,
    merge(effect$, names$)
);

const merged$ = merge(output$, effect$, dom$);

const log$ = getStream("[log]", inputs)(logHandler$, merged$);

log$.subscribe();

// resume$.next(true);
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:31,代码来源:index.ts

示例10: fromEvent

 this._change = platform.isBrowser ? ngZone.runOutsideAngular(() => {
   return merge<Event>(fromEvent(window, 'resize'), fromEvent(window, 'orientationchange'));
 }) : observableOf();
开发者ID:GuzmanPI,项目名称:material2,代码行数:3,代码来源:viewport-ruler.ts


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