Contentful Personalization & Analytics
    Preparing search index...

    Options that tweak the behavior of guardedBy.

    interface GuardedByOptions<T extends object> {
        invert?: boolean;
        onBlocked?: BlockHandler | (keyof T & (string | symbol));
    }

    Type Parameters

    • T extends object

      The instance type on which the decorator is applied.

    Index

    Properties

    Properties

    invert?: boolean

    Inverts the predicate result.

    When true, a truthy predicate result blocks the method. When false (default) or omitted, a truthy predicate result allows the method.

    false

    This option is useful when the predicate expresses a forbid condition (e.g. "isLocked" or "isDestroyed") rather than an allow condition.

    onBlocked?: BlockHandler | (keyof T & (string | symbol))

    Either a function to call when a method is blocked, or the name/symbol of an instance method on this to call when blocked.

    Both forms are synchronous and receive (methodName, argsArray). If omitted, blocked calls fail silently (i.e., return undefined or Promise<undefined> for async methods).

    • If a property key is supplied and the instance does not have a callable at that key, the hook is ignored.
    • The hook must not be async; any async work should be scheduled manually.