mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Adding memory to piper to reduce computation: https://stackoverflow.com/questions/77053367/rxjs-pipe-evaluates-too-often-then-breaks-in-anugular-app
This commit is contained in:
parent
7dc2a8a2ef
commit
c683ee71ab
@ -3,7 +3,7 @@ import {NetworkService} from '../../../model/network/network.service';
|
|||||||
import {FileDTO} from '../../../../../common/entities/FileDTO';
|
import {FileDTO} from '../../../../../common/entities/FileDTO';
|
||||||
import {Utils} from '../../../../../common/Utils';
|
import {Utils} from '../../../../../common/Utils';
|
||||||
import {ContentService} from '../content.service';
|
import {ContentService} from '../content.service';
|
||||||
import {mergeMap, Observable} from 'rxjs';
|
import {mergeMap, Observable, shareReplay} from 'rxjs';
|
||||||
import {MDFilesFilterPipe} from '../../../pipes/MDFilesFilterPipe';
|
import {MDFilesFilterPipe} from '../../../pipes/MDFilesFilterPipe';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -27,7 +27,7 @@ export class BlogService {
|
|||||||
.map(f => this.splitMarkDown(f, dates));
|
.map(f => this.splitMarkDown(f, dates));
|
||||||
|
|
||||||
return (await Promise.all(files)).flat();
|
return (await Promise.all(files)).flat();
|
||||||
}));
|
}), shareReplay(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async splitMarkDown(file: FileDTO, dates: number[]): Promise<GroupedMarkdown[]> {
|
private async splitMarkDown(file: FileDTO, dates: number[]): Promise<GroupedMarkdown[]> {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable, shareReplay} from 'rxjs';
|
||||||
import {GallerySortingService, GroupedDirectoryContent} from './navigator/sorting.service';
|
import {GallerySortingService, GroupedDirectoryContent} from './navigator/sorting.service';
|
||||||
import {FilterService} from './filter/filter.service';
|
import {FilterService} from './filter/filter.service';
|
||||||
import {ContentLoaderService} from './contentLoader.service';
|
import {ContentLoaderService} from './contentLoader.service';
|
||||||
@ -16,7 +16,7 @@ export class ContentService {
|
|||||||
this.sortedFilteredContent = this.sortingService
|
this.sortedFilteredContent = this.sortingService
|
||||||
.applySorting(
|
.applySorting(
|
||||||
this.filterService.applyFilters(this.contentLoaderService.originalContent)
|
this.filterService.applyFilters(this.contentLoaderService.originalContent)
|
||||||
);
|
).pipe(shareReplay(1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user