Options
All
  • Public
  • Public/Protected
  • All
Menu

Interceptors

Index

Type aliases

AccessInterceptor

AccessInterceptor: function

Interceptor for property-access. It is used with the access-decorator.

param

provide information about the property-access and allows the interceptor to forward the call to the next handler.

returns

For getters (access.setter === false), this is the value of the property, for setters true or false

example

access => {
  if(access.setter) {
    // Overwrite the value the property is to be set to
    access.value = "Hello"
    return access.next();
  }
  // getter
  let value = access.next();

  // Modify result
  value += 1;
  return value;
}
see

access

see

GetterInterceptor

see

SetterInterceptor

Type declaration

AfterInterceptor

AfterInterceptor: function

Interceptor that is invoked after a invocation has completed. It is used with the @after-decorator.

param

of the invocation

returns

Modified result of the invocation

example

result => {
  // Modify method result
  result += 1;
  return result;
}
see

after

see

MethodInterceptor

Type declaration

    • (result: any): any
    • Parameters

      • result: any

      Returns any

BeforeInterceptor

BeforeInterceptor: function

Interceptor that is invoked before a method invocation. It is used with the @before-decorator.

param

Arguments of the method invocation

returns

Modified arguments

example

args => {
  // Modify method arguments
  args.push("Additional argument");
  // Or swap them
  return ["Replacement", "Argument"];
}
see

after

see

MethodInterceptor

Type declaration

    • (args: any[]): any[]
    • Parameters

      • args: any[]

      Returns any[]

GetterInterceptor

GetterInterceptor: function

Interceptor for a property getter. It is used with the @getter-decorator.

param

of the property. This is (the potentially modified) value of the property.

returns

Modified value of the property.

example

value => {
  // Modify result
  value += 1;
  return value;
}
see

getter

see

AccessInterceptor

Type declaration

    • (value: any): any
    • Parameters

      • value: any

      Returns any

MethodInterceptor

MethodInterceptor: function

Interceptor for method invocations. It is used with the @around-decorator.

param

provide information about the invocation and allows the interceptor to forward the call to the next handler.

returns

The result of the method invocation

example

invocation => {
  // Access and modify argument
  invocation.args = ["Modified", "Arguments"];

  // Access and modify 'this'-context of the called method
  invocation.this = that;

  // Delegate call
  let result: any = invocation.next();

  // Modify result
  result += 1;
  return result;
}
see

around

see

AfterInterceptor

see

BeforeInterceptor

Type declaration

SetterInterceptor

SetterInterceptor: function

Interceptor for a property setter. It is used with the @setter-decorator.

param

to be assigned to the property (this has potentially already been modified by previous interceptor)

returns

Modified value to be assigned to the property.

example

value => {
  // Modify assigned value
  value += 1;
  return value;
}
see

setter

see

AccessInterceptor

Type declaration

    • (value: any): any
    • Parameters

      • value: any

      Returns any

Functions

access

  • Decorator for intercepting a read/write property-access.

    see

    AccessInterceptor

    Parameters

    Returns MethodDecorator & PropertyDecorator

after

  • Decorator for intercepting after a method invocation.

    see

    AfterInterceptor

    Parameters

    Returns function & function

around

  • Decorator for intercepting a method.

    see

    MethodInterceptor

    Parameters

    Returns MethodDecorator & PropertyDecorator

before

  • Decorator for intercepting before a method invocation.

    see

    BeforeInterceptor

    Parameters

    Returns function & function

getter

  • Decorator for intercepting a property read-access.

    see

    GetterInterceptor

    Parameters

    Returns function & function

proxy

  • proxy(): (Anonymous function)
  • Root decorator for classes. This is required on classes that use interceptors.

    see

    around

    see

    after

    see

    before

    see

    access

    see

    getter

    see

    setter

    example
    
    args => {
      // Modify method arguments
      args.push("Additional argument");
      // Or swap them
      return ["Replacement", "Argument"];
    }

    Returns (Anonymous function)

setter

  • Decorator for intercepting a property write-access.

    see

    SetterInterceptor

    Parameters

    Returns function & function

Generated using TypeDoc