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


TypeScript operators.shareReplay函數代碼示例

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


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

示例1: ngOnInit

 ngOnInit() {
   this.toolbarMode$ = this.store.select(fromStore.getToolbarMode).pipe(
     shareReplay());
   this.folders$ = this.store.select(fromStore.getAllFolders);
   this.currentFilter$ = this.store.select(fromStore.getCurrentFilter);
   this.folderView$ = this.store
     .select(fromStore.getCurrentFolder)
     .pipe(shareReplay());
   this.playlistView$ = this.store.select(fromStore.getCurrentPlaylist).pipe(shareReplay())
   this.selectedVideos$ = this.store
     .select(fromStore.getSelectedVideos)
     .pipe(shareReplay());
 }
開發者ID:ArmyMusicOnline,項目名稱:ami,代碼行數:13,代碼來源:toolbar.component.ts

示例2: _dispatch

    private _dispatch(action: any): Observable<any> {
        const meta = this[META_KEY] as StoreMetaInfo;
        if (!meta) {
            throw new Error(`${META_KEY} is not found, current store has not action`);
        }
        const actionMeta = meta.actions[action.type];
        if (!actionMeta) {
            throw new Error(`${action.type} is not found`);
        }
        let result: any = this[actionMeta.fn](this.snapshot, action.payload);

        if (result instanceof Promise) {
            result = from(result);
        }

        if (result instanceof Observable) {
            result = result.pipe(map(r => r));
        } else {
            result = Observable.create((observer: Observer<any>) => {
                observer.next({});
            });
            // result = of({});
        }
        return result.pipe(shareReplay());
    }
開發者ID:whyour,項目名稱:ngx-tethys,代碼行數:25,代碼來源:store.ts

示例3: getProjects

 getProjects(): Observable<Project[]> {
   return this.http.get<Project[]>('assets/data/projects.json')
     .pipe(
       map(res => res.map(r => ProjectModel(r))),
       shareReplay()
     );
 }
開發者ID:chriswoodley,項目名稱:cwoodley-com,代碼行數:7,代碼來源:projects.service.ts

示例4: getModules

  getModules(): Observable<Module[]> {
    if (!this.modulesCache$) {
      this.modulesCache$ = forkJoin(
        this.configService.getModules(), // names of the enabled modules
        this.toolResource.getModules() // all modules from the server
      ).pipe(
        map(results => {
          const enabledModules: string[] = results[0];
          const allModules: Module[] = results[1];
          return allModules
            .filter(
              (module: Module) => enabledModules.indexOf(module.name) >= 0
            )
            .map((module: Module) => {
              // set moduleId
              module.moduleId = module.name.toLowerCase();

              // create categoriesMap
              module.categoriesMap = UtilsService.arrayToMap(
                module.categories,
                "name"
              );

              return module;
            });
        }),
        shareReplay(1)
      );
    }
    return this.modulesCache$;
  }
開發者ID:chipster,項目名稱:chipster-web,代碼行數:31,代碼來源:tools.service.ts

示例5: discover

export function discover(config: PluginsConfig, coreContext: CoreContext) {
  const log = coreContext.logger.get('plugins-discovery');
  log.debug('Discovering plugins...');

  if (config.additionalPluginPaths.length) {
    log.warn(
      `Explicit plugin paths [${
        config.additionalPluginPaths
      }] are only supported in development. Relative imports will not work in production.`
    );
  }

  const discoveryResults$ = merge(
    from(config.additionalPluginPaths),
    processPluginSearchPaths$(config.pluginSearchPaths, log)
  ).pipe(
    mergeMap(pluginPathOrError => {
      return typeof pluginPathOrError === 'string'
        ? createPlugin$(pluginPathOrError, log, coreContext)
        : [pluginPathOrError];
    }),
    shareReplay()
  );

  return {
    plugin$: discoveryResults$.pipe(
      filter((entry): entry is PluginWrapper => entry instanceof PluginWrapper)
    ),
    error$: discoveryResults$.pipe(
      filter((entry): entry is PluginDiscoveryError => !(entry instanceof PluginWrapper))
    ),
  };
}
開發者ID:elastic,項目名稱:kibana,代碼行數:33,代碼來源:plugins_discovery.ts

示例6: ngOnInit

    ngOnInit () {
        this.playlist$ = this._route.paramMap.pipe(
            map(paramMap => ({ playlistId: paramMap.get('id'), playlistOwnerId: paramMap.get('user') })),
            switchMap(params =>
                this._spotifyService.getPlaylist(params.playlistOwnerId, params.playlistId)
            ),
            map(playlist => ({
                isLoading: false,
                result: playlist
            })),
            startWith({
                isLoading: true,
                result: null
            }),
            shareReplay()
        );

        this.tracks$ = this.playlist$.pipe(
            filter(o => !o.isLoading && !!o.result),
            map(o => o.result.Tracks)
        );

        this.playlistUrl$ = this.playlist$.pipe(
            filter(o => !o.isLoading && !!o.result),
            map(o => o.result),
            map(playlist => playlist.ImageUrls.length ? playlist.ImageUrls[0] : '')
        );
    }
開發者ID:Lightw3ight,項目名稱:PlayMeExtension,代碼行數:28,代碼來源:playlist.component.ts

示例7: combineLatest

 // Invokes hub method on subscription, stores replay.
 invokeAndListenFor<T>(method: string, listener: string, ...parameters: any[]): Observable<T> {
   return combineLatest(this.listenFor<T>(listener), this.invoke(method, ...parameters)).pipe(
     // Only pass the listenFor results
     map((x) => { return x[0]; }),
     // Keep the last result
     shareReplay(1)
   );
 }
開發者ID:Jameson42,項目名稱:KLUG-Derby,代碼行數:9,代碼來源:signalr.service.ts

示例8: getProject

 getProject(slug: string): Observable<Project> {
   return this.http.get<Project[]>('assets/data/projects.json')
     .pipe(
       map(res => res.map(r => ProjectModel(r))),
       map(projects => projects.find(p => p.slug.toLowerCase() === slug.toLowerCase())),
       shareReplay()
     );
 }
開發者ID:chriswoodley,項目名稱:cwoodley-com,代碼行數:8,代碼來源:projects.service.ts

示例9: getActionResultStream

 private getActionResultStream(action: any): Observable<ActionContext> {
   return this._actionResults.pipe(
     filter(
       (ctx: ActionContext) => ctx.action === action && ctx.status !== ActionStatus.Dispatched
     ),
     take(1),
     shareReplay()
   );
 }
開發者ID:LucasFrecia,項目名稱:store,代碼行數:9,代碼來源:dispatcher.ts

示例10: observe

	observe(key: string): Observable<any> {
		key = StorageKeyManager.normalize(key);
		return this.strategy.keyChanges.pipe(
			filter((changed: string) => changed === null || changed === key),
			switchMap(() => this.strategy.get(key)),
			distinctUntilChanged(),
			shareReplay()
		);
	}
開發者ID:PillowPillow,項目名稱:ng2-webstorage,代碼行數:9,代碼來源:asyncStorage.ts


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