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


TypeScript from.from函數代碼示例

本文整理匯總了TypeScript中rxjs/observable/from.from函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript from函數的具體用法?TypeScript from怎麽用?TypeScript from使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: constructor

  /**
   * Each Feature of AngularFire has a FirebaseApp injected. This way we
   * don't rely on the main Firebase App instance and we can create named
   * apps and use multiple apps.
   * @param app 
   */
  constructor(public app: FirebaseApp, shouldEnablePersistence) {
    this.firestore = app.firestore();

    this.persistenceEnabled$ = shouldEnablePersistence ? 
      from(app.firestore().enablePersistence().then(() => true)) :
      from(new Promise((res, rej) => { res(false); }));
  }
開發者ID:cartant,項目名稱:angularfire2,代碼行數:13,代碼來源:firestore.ts

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

示例3: reloadStyleImages

    function reloadStyleImages(style, styleNames: string[], path, expando): Observable<any> {
        return from(styleNames).pipe(
            filter(styleName => typeof style[styleName] === 'string')
            , map((styleName: string) => {
                let pathName;
                const value = style[styleName];
                const newValue = value.replace(new RegExp(`\\burl\\s*\\(([^)]*)\\)`), (match, src) => {
                    let _src = src;
                    if (src[0] === '"' && src[src.length-1] === '"') {
                        _src = src.slice(1, -1);
                    }
                    pathName = getLocation(_src).pathname;
                    if (pathsMatch(path, pathFromUrl(_src))) {
                        return `url(${generateCacheBustUrl(_src, expando)})`;
                    } else {
                        return match;
                    }
                });

                return [
                    style,
                    styleName,
                    value,
                    newValue,
                    pathName
                ];
            })
            , filter(([style, styleName, value, newValue]) => newValue !== value)
            , map(([style, styleName, value, newValue, pathName]) => styleSet({style, styleName, value, newValue, pathName}))
        )
    }
開發者ID:BrowserSync,項目名稱:browser-sync,代碼行數:31,代碼來源:Reloader.ts

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

示例5: reloadStylesheet

    function reloadStylesheet(path: string, document: Document, navigator): Observable<any> {
        // has to be a real array, because DOMNodeList will be modified
        const links: HTMLLinkElement[] = array(document.getElementsByTagName('link'))
            .filter(link => {
                return link.rel.match(/^stylesheet$/i)
                    && !link.__LiveReload_pendingRemoval;
            });

        /**
         * Find imported style sheets in <style> tags
         * @type {any[]}
         */
        const styleImported = array(document.getElementsByTagName('style'))
            .filter(style => Boolean(style.sheet))
            .reduce((acc, style) => {
                return acc.concat(collectImportedStylesheets(style, style.sheet));
            }, []);

        /**
         * Find imported style sheets in <link> tags
         * @type {any[]}
         */
        const linksImported = links
            .reduce((acc, link) => {
                return acc.concat(collectImportedStylesheets(link, link.sheet));
            }, []);

        /**
         * Combine all links + sheets
         */
        const allRules = links.concat(styleImported, linksImported);

        /**
         * Which href best matches the incoming href?
         */
        const match = pickBestMatch(path, allRules, l => pathFromUrl(linkHref(l)));

        if (match) {
            if (match.object && match.object.rule) {
                return reattachImportedRule(match.object, document);
            }
            return reattachStylesheetLink(match.object, document, navigator);
        } else {
            if (links.length) {
                // no <link> elements matched, so was the path including '*'?
                const [first, ...rest] = path.split('.');
                if (first === '*') {
                    return from(links.map(link => reattachStylesheetLink(link, document, navigator)))
                        .pipe(mergeAll())
                }
            }
        }

        return empty();
    }
開發者ID:BrowserSync,項目名稱:browser-sync,代碼行數:55,代碼來源:Reloader.ts

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

示例7: processRoutes

  private processRoutes(ngModule: NgModuleRef<any>, routes: Routes): Observable<void> {
    const res: Observable<any>[] = [];
    for (const route of routes) {
      // we already have the config loaded, just recurse
      if (route.loadChildren && !route.canLoad && route._loadedConfig) {
        const childConfig = route._loadedConfig;
        res.push(this.processRoutes(childConfig.module, childConfig.routes));

        // no config loaded, fetch the config
      } else if (route.loadChildren && !route.canLoad) {
        res.push(this.preloadConfig(ngModule, route));

        // recurse into children
      } else if (route.children) {
        res.push(this.processRoutes(ngModule, route.children));
      }
    }
    return mergeAll.call(from(res));
  }
開發者ID:AnthonyPAlicea,項目名稱:angular,代碼行數:19,代碼來源:router_preloader.ts

示例8: from

 downloadURL: () => from(task.then(s => s.downloadURL)),
開發者ID:acipher,項目名稱:angularfire2,代碼行數:1,代碼來源:task.ts

示例9: from

 const fakeStore = { select: () => from([{} as AppState])} as any as Store<AppState>;
開發者ID:mhoyer,項目名稱:ng2-kanban,代碼行數:1,代碼來源:board.component.spec.ts

示例10: from

 updateMetatdata: (meta: SettableMetadata) => from(ref.updateMetadata(meta)),
開發者ID:acipher,項目名稱:angularfire2,代碼行數:1,代碼來源:ref.ts


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