Sanity Library Reference Docs
    Preparing search index...

    Props the default export of a web worker's src file receives when the worker starts. It can return a disposer, which runs when Dashboard stops the worker.

    import {type WebWorkerProps} from '@sanity/sdk-react/dashboard'

    export default ({bus}: WebWorkerProps) => {
    const controller = new AbortController()
    bus.subscribe('workers.post', (message) => message.reply(snapshot), {
    signal: controller.signal,
    })
    return () => controller.abort()
    }
    interface WebWorkerProps {
        bus: Omit<MessageBus<MessageBusTopics>, "subscribe"> & {
            subscribe<K extends EventTopic>(
                type: K,
                handler: (
                    message: MessageBusMessage<PayloadOf<K>, ReplyOf<K>, K>,
                ) => void,
                options?: MessageBusAbortOptions,
            ): void;
            subscribe<K extends StateTopic>(
                type: K,
                handler: (value: ValueOf<K>) => void,
                options?: MessageBusAbortOptions,
            ): void;
        };
        worker: { name: string; type: string };
    }
    Index

    Properties

    Properties

    bus: Omit<MessageBus<MessageBusTopics>, "subscribe"> & {
        subscribe<K extends EventTopic>(
            type: K,
            handler: (message: MessageBusMessage<PayloadOf<K>, ReplyOf<K>, K>) => void,
            options?: MessageBusAbortOptions,
        ): void;
        subscribe<K extends StateTopic>(
            type: K,
            handler: (value: ValueOf<K>) => void,
            options?: MessageBusAbortOptions,
        ): void;
    }

    The message bus, with a subscribe that takes a handler so the worker doesn't need rxjs.

    Type declaration

    worker: { name: string; type: string }