X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Frouting%2Fpreload-selected-modules-list.ts;h=1abcdb01514c12df0a8ecceeca7ca76d04980802;hb=HEAD;hp=dd5be6ad948c9886cc668f1600f10118a4c17618;hpb=a685e25ca05f08ad1b3f7fbaccc8744727bd8d27;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/routing/preload-selected-modules-list.ts b/client/src/app/core/routing/preload-selected-modules-list.ts index dd5be6ad9..1abcdb015 100644 --- a/client/src/app/core/routing/preload-selected-modules-list.ts +++ b/client/src/app/core/routing/preload-selected-modules-list.ts @@ -1,16 +1,18 @@ -import { Route, PreloadingStrategy } from '@angular/router'; -import { Observable } from 'rxjs/Observable'; -import 'rxjs/add/observable/timer'; -import 'rxjs/add/operator/switchMap'; +import { Observable, of as ofObservable, timer as observableTimer } from 'rxjs' +import { switchMap } from 'rxjs/operators' +import { Injectable } from '@angular/core' +import { PreloadingStrategy, Route } from '@angular/router' +@Injectable() export class PreloadSelectedModulesList implements PreloadingStrategy { - preload(route: Route, load: Function): Observable { - if (!route.data || !route.data.preload) return Observable.of(null); + + preload (route: Route, load: () => Observable): Observable { + if (!route.data?.preload) return ofObservable(null) if (typeof route.data.preload === 'number') { - return Observable.timer(route.data.preload).switchMap(() => load()); + return observableTimer(route.data.preload).pipe(switchMap(() => load())) } - return load(); + return load() } }