remix-utils-rt
Version:
This package contains simple utility functions to use with [React Router](https://reactrouter.com/home).
18 lines (17 loc) • 653 B
TypeScript
export interface EventSourceOptions {
init?: EventSourceInit;
event?: string;
enabled?: boolean;
}
export type EventSourceMap = Map<string, {
count: number;
source: EventSource;
}>;
export declare const EventSourceProvider: import("react").Provider<EventSourceMap>;
/**
* Subscribe to an event source and return the latest event.
* @param url The URL of the event source to connect to
* @param options The options to pass to the EventSource constructor
* @returns The last event received from the server
*/
export declare function useEventSource(url: string | URL, { event, init, enabled }?: EventSourceOptions): string | null;