import { useState, useEffect } from "react";
import {
  isStreamingEnabled,
  subscribeToStreaming,
  setStreamingEnabled,
  toggleStreaming
} from "../state/streaming-state.js";
function useStreaming() {
  const [streaming, setStreamingState] = useState(isStreamingEnabled);
  useEffect(() => {
    const unsubscribe = subscribeToStreaming((enabled) => {
      setStreamingState(enabled);
    });
    return unsubscribe;
  }, []);
  return {
    streaming,
    setStreaming: setStreamingEnabled,
    toggleStreaming
  };
}
export {
  useStreaming
};
