pnwkit 3.0 - v4.3.0
    Preparing search index...

    Interface SubscribeOptions<M, Bulk>

    await pnwkit.subscriptions.subscribe({
    model: "nation",
    event: "update",
    filters: { alliance_id: "1234" },
    onData: (nation) => console.log(nation.id, nation.nation_name),
    });
    interface SubscribeOptions<M extends Model, Bulk extends boolean = false> {
        apiKey?: string;
        bulk?: Bulk;
        event: Event;
        filters?: SubscriptionParams;
        model: M;
        onData: (
            data: Bulk extends true
                ? SubscriptionModels[M][]
                : SubscriptionModels[M],
        ) => void;
        onError?: (error: Error) => void;
    }

    Type Parameters

    • M extends Model

      The model being subscribed to; drives the type of onData.

    • Bulk extends boolean = false

      Whether this is a bulk subscription (delivers arrays).

    Index
    apiKey?: string

    Optional API key to authenticate this subscription with, overriding the client's default key.

    bulk?: Bulk

    Set to true to receive batched events as arrays instead of one at a time.

    event: Event

    The lifecycle event to listen for.

    Optional server-side filters to narrow the event stream.

    model: M

    The model to subscribe to.

    onData: (
        data: Bulk extends true
            ? SubscriptionModels[M][]
            : SubscriptionModels[M],
    ) => void

    Called for each event, with the payload typed to the subscribed model (an array when bulk is true).

    onError?: (error: Error) => void

    Optional handler for network/parse/rollback errors on this subscription.