packageDocumentation module import { useEffect } from "react" ; import { Interpreter , StateSchema , EventObject , Typestate } from "xstate" ; typeparam typeparam typeparam typeparam param service param name export const useServiceLogger = < TContext , TStateSchema extends StateSchema = any , TEvent extends EventObject = EventObject , TTypestate extends Typestate < TContext > = any > ( service , name ? ) => useEffect ( ( ) => { let i = 0 ; const subscription = service . subscribe ( nextState => { if ( name ) { console . groupCollapsed ( `${ name } (${ ++ i })` ) ; } console . log ( JSON . stringify ( nextState . value , null , 2 ) ) ; console . log ( JSON . stringify ( nextState . context , null , 2 ) ) ; console . log ( nextState ) ; if ( name ) { console . groupEnd ( ) ; } return ( ) => { subscription . unsubscribe ( ) ; } ; } ) ; } , [ service , name ] ) ; export default useServiceLogger ;