Skip to content

Commit

Permalink
feat: add getters to machine meta
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Apr 25, 2022
1 parent a1ea869 commit b396be7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ export class Machine<
send: this.send.bind(this),
self: this.self,
getState: () => this.stateSnapshot,
getAction: (key) => this.actionMap[key],
getGuard: (key) => this.guardMap[key],
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export declare namespace StateMachine {
send: Send<TEvent>
self: Self<TContext, TState, TEvent>
getState: () => State<TContext, TState, TEvent>
getAction: (key: string) => ExpressionWithMeta<TContext, TState, TEvent, void>
getGuard: (key: string) => GuardExpression<TContext, TEvent>
}

type ExpressionWithMeta<TContext extends Dict, TState extends StateSchema, TEvent extends EventObject, TReturn> = (
Expand Down

0 comments on commit b396be7

Please sign in to comment.