Angular Preload OptIn

    0

    0

    Jose Romero

    Angular TypeScript Recipes

    The PreloadSelectedModulesList class implements the PreloadingStrategy interface. When the preload() method is called, the load() method will be executed if the route's data property has a preload value. Otherwise, the of() method will return null.

    Library: angular

    Shortcut: angular.preload.optin

    import { PreloadingStrategy, Route } from '@angular/router';
    import { Observable, of } from 'rxjs';
    
    export class PreloadSelectedModulesList implements PreloadingStrategy {
      preload(route: Route, load: Function): Observable<any> {
        return route.data && route.data['preload'] ? load() : of(null);
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.