• @Pre decorator defines a function computed before reading or writing the value of the decorated property or class .

    It is typically used for pre-processing tasks such as debugging, to run operation on the Cursor instance at runtime.

    Type Parameters

    • This

      The type of the class the decorator is applied to.

    Parameters

    • func: PrePostFunction<This>

      Function that will be executed before the property or class has been processed, that receive the instance and cursor value as argument.

    • Optionalopt: Partial<PrePostOptions>

      Optional configution.

    Returns ClassAndPropertyDecoratorType<This>

    The class or property decorator function.

    In the following example, the @Pre operator is used read the value of the cursor and make a debug log to notify the position where the type definition start to be read.

    @Pre((_, cursor) => { console.log(`${_.constructor.name} : ${cursor.offset()}`) })
    class Protocol {
    @Pre((_, cursor) => { console.log(`${_.constructor.name} : ${cursor.offset()}`) })
    @Relation(PrimitiveSymbol.u8)
    foo: number
    }