本文整理汇总了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;未经允许,请勿转载。 |
请发表评论