Page Contents

Home > @loopback/context > mergeInterceptors

mergeInterceptors() function

Adding interceptors from the spec to the front of existing ones. Duplicate entries are eliminated from the spec side.

For example:

  • [log] + [cache, log] => [cache, log] - [log] + [log, cache] => [log, cache] - [] + [cache, log] => [cache, log] - [cache, log] + [] => [cache, log] - [log] + [cache] => [log, cache]

Signature:

export declare function mergeInterceptors(interceptorsFromSpec: InterceptorOrKey[], existingInterceptors: InterceptorOrKey[]): GenericInterceptorOrKey<InvocationContext>[];

Parameters

Parameter Type Description
interceptorsFromSpec InterceptorOrKey[] Interceptors from @intercept
existingInterceptors InterceptorOrKey[] Interceptors already applied for the method

Returns:

GenericInterceptorOrKey<InvocationContext>[]