-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from aod/xstate5
Migrate to XState v5
- Loading branch information
Showing
22 changed files
with
691 additions
and
530 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import { createContext, PropsWithChildren } from "react"; | ||
import { useInterpret } from "@xstate/react"; | ||
import { createActorContext } from "@xstate/react"; | ||
import { createBrowserInspector } from "@statelyai/inspect"; | ||
|
||
import { zhitheadMachine } from "../../state/machines/zhithead.machine"; | ||
import { InterpreterFrom } from "xstate"; | ||
|
||
export const GlobalStateContext = createContext({ | ||
zhitheadService: {} as InterpreterFrom<typeof zhitheadMachine>, | ||
}); | ||
declare global { | ||
interface Window { | ||
inspector: ReturnType<typeof createBrowserInspector> | undefined; | ||
} | ||
} | ||
|
||
export default function GlobalStateProvider(props: PropsWithChildren) { | ||
const zhitheadService = useInterpret(zhitheadMachine); | ||
const inspector = createBrowserInspector({ | ||
autoStart: false, | ||
}); | ||
window.inspector = inspector; | ||
|
||
return ( | ||
<GlobalStateContext.Provider value={{ zhitheadService }}> | ||
{props.children} | ||
</GlobalStateContext.Provider> | ||
); | ||
} | ||
export const GlobalStateContext = createActorContext(zhitheadMachine, { | ||
inspect: inspector.inspect, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.