optimize song list load
This commit is contained in:
17
src/app/modules/songs/services/song-list.resolver.ts
Normal file
17
src/app/modules/songs/services/song-list.resolver.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Resolve} from '@angular/router';
|
||||
import {Observable} from 'rxjs';
|
||||
import {SongService} from './song.service';
|
||||
import {Song} from './song';
|
||||
import {filter} from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SongListResolver implements Resolve<Song[]> {
|
||||
public constructor(private songService: SongService) {}
|
||||
|
||||
public resolve(): Observable<Song[]> {
|
||||
return this.songService.list$().pipe(filter(_ => _.length > 0));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user