Page Contents

Home > @loopback/boot > BootMixin

BootMixin() function

Mixin for @loopback/boot. This Mixin provides the following: - Implements the Bootable Interface as follows. - Add a projectRoot property to the Class - Adds an optional bootOptions property to the Class that can be used to store the Booter conventions. - Adds the BootComponent to the Class (which binds the Bootstrapper and default Booters) - Provides the boot() convenience method to call Bootstrapper.boot() - Provides the booter() convenience method to bind a Booter(s) to the Application - Override component() to call mountComponentBooters - Adds mountComponentBooters which binds Booters to the application from component.booters[]

******************** NOTE ******************** Trying to constrain the type of this Mixin (or any Mixin) will cause errors. For example, constraining this Mixin to type Application require all types using by Application to be imported (including it’s dependencies such as ResolutionSession). Another issue was that if a Mixin that is type constrained is used with another Mixin that is not, it will result in an error. Example (class MyApp extends BootMixin(RepositoryMixin(Application))) {}; ******************** END OF NOTE ********************

Signature:

export declare function BootMixin<T extends Constructor<any>>(superClass: T): {
    new (...args: any[]): {
        [x: string]: any;
        projectRoot: string;
        bootOptions?: BootOptions | undefined;
        boot(): Promise<void>;
        booters(...booterCls: Constructor<Booter>[]): Binding<any>[];
        component(component: Constructor<{}>): void;
        mountComponentBooters(component: Constructor<{}>): void;
    };
} & T;

Parameters

Parameter Type Description
superClass T  

Returns:

{ new (...args: any[]): { [x: string]: any; projectRoot: string; bootOptions?: BootOptions | undefined; boot(): Promise<void>; booters(...booterCls: Constructor<Booter>[]): Binding<any>[]; component(component: Constructor<{}>): void; mountComponentBooters(component: Constructor<{}>): void; }; } & T