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


TypeScript mergeMap.mergeMap函数代码示例

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


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

示例1: getBibSummary

    // Note when multiple IDs are provided, responses are emitted in order
    // of receipt, not necessarily in the requested ID order.
    getBibSummary(bibIds: number | number[],
        orgId?: number, orgDepth?: number): Observable<BibRecordSummary> {

        const ids = [].concat(bibIds);

        if (ids.length === 0) {
            return from([]);
        }

        return this.pcrud.search('bre', {id: ids},
            {   flesh: 1,
                flesh_fields: {bre: ['flat_display_entries', 'mattrs']},
                select: {bre : this.fetchableBreFields()}
            },
            {anonymous: true} // skip unneccesary auth
        ).pipe(mergeMap(bib => {
            const summary = new BibRecordSummary(bib, orgId, orgDepth);
            summary.net = this.net; // inject
            summary.ingest();
            return this.getHoldingsSummary(bib.id(), orgId, orgDepth)
            .then(holdingsSummary => {
                summary.holdingsSummary = holdingsSummary;
                return summary;
            });
        }));
    }
开发者ID:jamesrf,项目名称:Evergreen,代码行数:28,代码来源:bib-record.service.ts

示例2: incomingBrowserReload

export function incomingBrowserReload(xs: Observable<any>, inputs: Inputs) {
    return xs.pipe(
        withLatestFrom(inputs.option$),
        filter(([event, options]) => options.codeSync),
        mergeMap(reloadBrowserSafe)
    );
}
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:7,代码来源:BrowserReload.ts

示例3: mergeMap

                    mergeMap(({ selector, styleNames }) => {
                        return from(document.querySelectorAll(`[style*=${selector}]`)).pipe(
                            mergeMap((img: HTMLImageElement) => {
                                return reloadStyleImages(img.style, styleNames, path, expando);
                            })
                        )

                    })
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:8,代码来源:Reloader.ts

示例4: function

 return function(handlers$, inputStream$) {
     return inputStream$.pipe(
         groupBy(([keyName]) => {
             return keyName;
         }),
         withLatestFrom(handlers$),
         filter(([x, handlers]) => {
             return typeof handlers[x.key] === "function";
         }),
         mergeMap(([x, handlers]) => {
             return handlers[x.key](x.pipe(pluck(String(1))), inputs);
         }),
         share()
     );
 };
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:15,代码来源:index.ts

示例5: fileReloadEffect

export function fileReloadEffect(
    xs: Observable<FileReloadEventPayload>,
    inputs: Inputs
) {
    return xs.pipe(
        withLatestFrom(inputs.option$, inputs.document$, inputs.navigator$),
        mergeMap(([event, options, document, navigator]) => {
            return reload(document, navigator)(event, {
                tagNames: options.tagNames,
                liveCSS: true,
                liveImg: true
            });
        })
    );
}
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:15,代码来源:file-reload.effect.ts

示例6: reattachImportedRule

    function reattachImportedRule({ rule, index, link }, document: Document): Observable<any> {
        const parent  = rule.parentStyleSheet;
        const href    = generateCacheBustUrl(rule.href);
        const media   = rule.media.length ? [].join.call(rule.media, ', ') : '';
        const newRule = `@import url("${href}") ${media};`;

        // used to detect if reattachImportedRule has been called again on the same rule
        rule.__LiveReload_newHref = href;

        // WORKAROUND FOR WEBKIT BUG: WebKit resets all styles if we add @import'ed
        // stylesheet that hasn't been cached yet. Workaround is to pre-cache the
        // stylesheet by temporarily adding it as a LINK tag.
        const tempLink = document.createElement("link");
        tempLink.rel = 'stylesheet';
        tempLink.href = href;
        tempLink.__LiveReload_pendingRemoval = true;  // exclude from path matching

        if (link.parentNode) {
            link.parentNode.insertBefore(tempLink, link);
        }

        return timer(200)
            .pipe(
                tap(() => {
                    if (tempLink.parentNode) { tempLink.parentNode.removeChild(tempLink); }

                    // if another reattachImportedRule call is in progress, abandon this one
                    if (rule.__LiveReload_newHref !== href) { return; }

                    parent.insertRule(newRule, index);
                    parent.deleteRule(index+1);

                    // save the new rule, so that we can detect another reattachImportedRule call
                    rule = parent.cssRules[index];
                    rule.__LiveReload_newHref = href;
                })
                , mergeMap(() => {
                    return timer(200).pipe(
                        tap(() => {
                            // if another reattachImportedRule call is in progress, abandon this one
                            if (rule.__LiveReload_newHref !== href) { return; }
                            parent.insertRule(newRule, index);
                            return parent.deleteRule(index+1);
                        })
                    )
                })
            );
    }
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:48,代码来源:Reloader.ts

示例7: incomingFileReload

export function incomingFileReload(
    xs: Observable<FileReloadEventPayload>,
    inputs: Inputs
) {
    return xs.pipe(
        withLatestFrom(inputs.option$),
        filter(([event, options]) => options.codeSync),
        mergeMap(([event, options]) => {
            if (event.url || !options.injectChanges) {
                return reloadBrowserSafe();
            }
            if (event.basename && event.ext && isBlacklisted(event)) {
                return empty();
            }
            return of(fileReload(event));
        })
    );
}
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:18,代码来源:FileReload.ts

示例8: incomingConnection

export function incomingConnection(
    xs: Observable<IBrowserSyncOptions>,
    inputs: Inputs
) {
    return xs.pipe(
        withLatestFrom(inputs.option$.pipe(pluck("logPrefix"))),
        mergeMap(([x, logPrefix]) => {

            const prefix = logPrefix
                ? `${logPrefix}: `
                : '';

            return of<any>(
                setOptions(x),
                Log.overlayInfo(`${prefix}connected`)
            );
        })
    );
}
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:19,代码来源:Connection.ts

示例9: 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

示例10: reattachStylesheetLink

    function reattachStylesheetLink(link: HTMLLinkElement, document: Document, navigator: Navigator): Observable<any> {
        // ignore LINKs that will be removed by LR soon
        let clone;

        if (link.__LiveReload_pendingRemoval) {
            return empty();
        }
        link.__LiveReload_pendingRemoval = true;

        if (link.tagName === 'STYLE') {
            // prefixfree
            clone = document.createElement('link');
            clone.rel      = 'stylesheet';
            clone.media    = link.media;
            clone.disabled = link.disabled;
        } else {
            clone = link.cloneNode(false);
        }

        const prevHref = link.href;
        const nextHref = generateCacheBustUrl(linkHref(link));
        clone.href = nextHref;

        const {pathname} = getLocation(nextHref);
        const basename = pathname.split('/').slice(-1)[0];

        // insert the new LINK before the old one
        const parent = link.parentNode;
        if (parent.lastChild === link) {
            parent.appendChild(clone);
        } else {
            parent.insertBefore(clone, link.nextSibling);
        }

        let additionalWaitingTime;
        if (/AppleWebKit/.test(navigator.userAgent)) {
            additionalWaitingTime = 5;
        } else {
            additionalWaitingTime = 200;
        }

        return Observable.create(obs => {
            clone.onload = () => {
                obs.next(true);
                obs.complete()
            };
        })
            .pipe(
                mergeMap(() => {
                    return timer(additionalWaitingTime)
                        .pipe(
                            tap(() => {
                                if (link && !link.parentNode) {
                                    return;
                                }
                                link.parentNode.removeChild(link);
                                clone.onreadystatechange = null;
                            })
                            , mapTo(linkReplace({target: clone, nextHref, prevHref, pathname, basename}))
                        )
                })
            )
    }
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:63,代码来源:Reloader.ts


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