@kentcdodds/tmp-remix-utils
Version:
This package contains simple utility functions to use with [Remix.run](https://remix.run).
24 lines (23 loc) • 663 B
TypeScript
/// <reference types="react" />
export interface EventSourceOptions {
init?: EventSourceInit;
event?: string;
}
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 }?: EventSourceOptions
): string | null;