Page Contents

Home > @loopback/core > extensions

extensions() function

Shortcut to inject extensions for the given extension point.

Signature:

export declare function extensions(extensionPointName?: string): (target: Object, member: string, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;

Parameters

Parameter Type Description
extensionPointName string Name of the extension point. If not supplied, we use the name 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 extensionPointName for different types of extensions.

Returns:

(target: Object, member: string, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void

Example

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[]>,
   // ...
) {
  // ...
}