@loopback/docs
Version:
Documentation for LoopBack 4
57 lines (40 loc) • 1.74 kB
Markdown
lang: en
title: 'API docs: service-proxy.servicemixin'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.service-proxy.servicemixin.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/service-proxy](./service-proxy.md) > [ServiceMixin](./service-proxy.servicemixin.md)
## 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.
<b>Signature:</b>
```typescript
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 | <code>T</code> | |
<b>Returns:</b>
`{
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
```ts
class MyApplication extends ServiceMixin(Application) {}
```
Please note: the members in the mixin function are documented in a dummy class called <a href="#ServiceMixinDoc">ServiceMixinDoc</a>