From 1857b4474a47901df5fc9e84839d912caf1f05c8 Mon Sep 17 00:00:00 2001 From: Avraham Sakal Date: Wed, 17 May 2023 10:06:25 -0400 Subject: [PATCH] add subscribe method to interpreter --- src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.ts b/src/index.ts index 46fd251..e5ca1e4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -46,6 +46,7 @@ export interface Interpreter_T { isTransitioning: boolean; isPaused: boolean; start: ()=>Interpreter_T; + subscribe: (callback:SubscriptionCallbackFunction_T)=>Interpreter_T; } /** @@ -62,6 +63,7 @@ export function Interpreter(machine:Machine_T, initialContext:any, initial //@ts-expect-error const interpreter : Interpreter_T = {machine, state: initialStateName, context:initialContext, eventQueue:[], isTransitioning:false, subscriptions: {}, isPaused: true}; interpreter.start = ()=>{ start(interpreter); return interpreter; } + interpreter.subscribe = (callback)=>{ subscribe(interpreter,callback); return interpreter; } send(interpreter, ['entry', null] ); return interpreter; }