@loopback/docs
Version:
Documentation for LoopBack 4
53 lines (35 loc) • 1.63 kB
Markdown
lang: en
title: 'API docs: core.extensions'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.core.extensions.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/core](./core.md) > [extensions](./core.extensions.md)
## extensions() function
Shortcut to inject extensions for the given extension point.
<b>Signature:</b>
```typescript
export declare function extensions(extensionPointName?: string): (target: Object, member: string, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| extensionPointName | <code>string</code> | Name of the extension point. If not supplied, we use the <code>name</code> tag from the extension point binding or the class name of the extension point class. If a class needs to inject extensions from multiple extension points, use different <code>extensionPointName</code> for different types of extensions. |
<b>Returns:</b>
`(target: Object, member: string, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void`
## Example
```ts
import {Getter} from '@loopback/context';
import {extensionPoint, extensions} from '@loopback/core';
@extensionPoint(GREETER_EXTENSION_POINT_NAME)
export class GreetingService {
constructor(
@extensions() // Inject extensions for the extension point
private getGreeters: Getter<Greeter[]>,
// ...
) {
// ...
}
```