Page Contents

Home > @loopback/service-proxy > ServiceMixin

ServiceMixin() function

A mixin class for Application that creates a .serviceProvider() function to register a service automatically. Also overrides component function to allow it to register repositories automatically.

Signature:

export declare function ServiceMixin<T extends Class<any>>(superClass: T): {
    new (...args: any[]): {
        [x: string]: any;
        serviceProvider<S>(provider: Class<Provider<S>>, name?: string | undefined): Binding<S>;
        component(component: Class<unknown>, name?: string | undefined): void;
        mountComponentServices(component: Class<unknown>): void;
    };
} & T;

Parameters

Parameter Type Description
superClass T  

Returns:

{ new (...args: any[]): { [x: string]: any; serviceProvider<S>(provider: Class<Provider<S>>, name?: string | undefined): Binding<S>; component(component: Class<unknown>, name?: string | undefined): void; mountComponentServices(component: Class<unknown>): void; }; } & T

Example

class MyApplication extends ServiceMixin(Application) {}

Please note: the members in the mixin function are documented in a dummy class called ServiceMixinDoc