UNPKG

stream-hooks

Version:

<div align="center"> <a aria-label="NPM version" href="https://twitter.com/dimitrikennedy"> <img alt="stream-hooks" src="https://img.shields.io/twitter/follow/dimitrikennedy?style=social&labelColor=000000"> </a> <a aria-label="GH Issues" href="h

31 lines (28 loc) 871 B
import { UseStreamProps, StartStreamBase, StopStream } from '../types/index.mjs'; import 'zod'; /** * `useStream` is a custom React hook that creates a fetch request to a stream endpoint and manages the state of that stream * It provides functionalities to start and stop the stream, and manages the loading state. * * @param {UseStreamProps} props - The props for the hook include optional callback * functions that will be invoked at different stages of the stream lifecycle. * * @returns { * startStream: StartStream, * stopStream: StopStream * } * * @example * ``` * const { * loading, * startStream, * stopStream * } = useStream({ onBeforeStart: ..., onStop: ... }); * ``` */ declare function useStream({ onBeforeStart, onStop }: UseStreamProps): { startStream: StartStreamBase; stopStream: StopStream; }; export { useStream };