annotations-design-patterns
    Preparing search index...

    Function Intercept

    • Interpone un interceptor entre el llamante y el método (patrón Proxy). El interceptor decide si delega (invocation.proceed()), cortocircuita devolviendo otro valor, o modifica argumentos antes de delegar.

      Type Parameters

      • This
      • Args extends unknown[]
      • Return

      Parameters

      Returns (
          target: (this: This, ...args: Args) => Return,
          context: ClassMethodDecoratorContext<
              This,
              (this: This, ...args: Args) => Return,
          >,
      ) => (this: This, ...args: Args) => Return

      class Api {
      @Intercept<Api, [string], User>((inv) => {
      console.log('llamando', inv.methodName);
      return inv.proceed();
      })
      getUser(id: string): User { ... }
      }