pure
    Preparing search index...

    Type Alias EmpConstructor<T, TRepr>

    type EmpConstructor<T, TRepr> = {
        free: (ptr: TRepr) => void | Promise<void>;
        marker?: T;
    }

    Type Parameters

    • T
    • TRepr
    Index

    Properties

    Properties

    free: (ptr: TRepr) => void | Promise<void>

    Function to free the underlying object. Called when this Emp is garbage-collected

    marker?: T

    The marker for the Emp type, used to distinguish between multiple types

    Typically, this is a unique symbol:

    const MyNativeType = Symbol("MyNativeType");
    export type MyNativeType = typeof MyNativeType;

    const makeMyNativeTypeEmp = makeEmpType({
    marker: MyNativeType,
    free: (ptr) => void freeMyNativeType(ptr)
    })

    Note that this is not used in runtime, but just used for type inference, so you can also skip passing it and specify the type parameter instead