remix-utils-rt
Version: 
This package contains simple utility functions to use with [React Router](https://reactrouter.com/home).
20 lines (19 loc) • 741 B
TypeScript
interface SendFunctionArgs {
    /**
     * @default "message"
     */
    event?: string;
    data: string;
}
type SendFunction = (args: SendFunctionArgs) => void;
type CleanupFunction = () => void;
type AbortFunction = () => void;
type InitFunction = (send: SendFunction, abort: AbortFunction) => CleanupFunction;
/**
 * A response helper to use Server Sent Events server-side
 * @param signal The AbortSignal used to close the stream
 * @param init The function that will be called to initialize the stream, here you can subscribe to your events
 * @returns A Response object that can be returned from a loader
 */
export declare function eventStream(signal: AbortSignal, init: InitFunction, options?: ResponseInit): Response;
export {};