import { createContext, useContext, useState, ReactNode } from 'react' /* This is for a very small handful of global state we need that doesn't fit into any of the Xstate machines. Please do not fill this up with junk. */ interface AppState { isStreamReady: boolean setAppState: (newAppState: Partial) => void } const AppStateContext = createContext({ isStreamReady: false, setAppState: () => {}, }) export const useAppState = () => useContext(AppStateContext) export const AppStateProvider = ({ children }: { children: ReactNode }) => { const [appState, _setAppState] = useState({ isStreamReady: false, setAppState: () => {}, }) const setAppState = (newAppState: Partial) => _setAppState({ ...appState, ...newAppState }) return ( {children} ) }