statelyai / inspect

Inspect state transitions and actor communication
https://stately.ai/docs/inspector
MIT License
45 stars 5 forks source link

Inspector not working with @xstate/react createActorContext #5

Closed NoobleMcScrunchkin closed 9 months ago

NoobleMcScrunchkin commented 9 months ago

Hiya,

Lovely to see updated inspector being released! I have looked into trying to add this on to my @xstate/react machines and contexts that are using createActorContext and I can't seem to get them to work after adding in {inspect: inspector.inspect} into the createActorContext function. Is there something else you have to do to get this to work? It seems to work fine with createActor from the usual xstate package but not xstate/react.

import { createActorContext } from "@xstate/react";
import { createBrowserInspector } from '@statelyai/inspect';

const inspector = createBrowserInspector();
const actorContext = createActorContext(stateMachine, {inspect: inspector.inspect}); // Error is highlighted here also: Type 'Observer<InspectionEvent>' is not assignable to type 'Observer<InspectionEvent> | ((inspectionEvent: InspectionEvent) => void) | undefined'. 
davidkpiano commented 9 months ago

This is now fixed here: https://github.com/statelyai/xstate/pull/4695