Page Contents

Home > @loopback/context > Binding > apply

Binding.apply() method

Apply one or more template functions to set up the binding with scope, tags, and other attributes as a group.

Signature:

apply(...templateFns: BindingTemplate<T>[]): this;

Parameters

Parameter Type Description
templateFns BindingTemplate<T>[] One or more functions to configure the binding

Returns:

this

Example

const serverTemplate = (binding: Binding) =>
  binding.inScope(BindingScope.SINGLETON).tag('server');

const serverBinding = new Binding<RestServer>('servers.RestServer1');
serverBinding.apply(serverTemplate);