Comparing version 0.2.18 to 0.2.19
@@ -10,3 +10,3 @@ declare module 'robot3' { | ||
*/ | ||
export function createMachine<S, C>( | ||
export function createMachine<S = {}, C = {}>( | ||
initial: keyof S, | ||
@@ -23,3 +23,3 @@ states: { [K in keyof S]: MachineState }, | ||
*/ | ||
export function createMachine<S, C>( | ||
export function createMachine<S = {}, C = {}>( | ||
states: { [K in keyof S]: MachineState }, | ||
@@ -98,7 +98,21 @@ context?: ContextFunction<C> | ||
export function invoke(...args: any[]): any | ||
/** | ||
* The `invoke` is a special type of state that immediately invokes a Promise-returning function or another machine. | ||
* | ||
* @param fn - Promise-returning function | ||
* @param args - Any argument needs to be of type Transition or Immediate. | ||
*/ | ||
export function invoke<C, T>(fn: (ctx: C) => Promise<T>, ...args: (Transition | Immediate)[]): MachineState | ||
/** | ||
* The `invoke` is a special type of state that immediately invokes a Promise-returning function or another machine. | ||
* | ||
* @param machine - Machine | ||
* @param args - Any argument needs to be of type Transition or Immediate. | ||
*/ | ||
export function invoke<M extends Machine>(machine: M, ...args: (Transition | Immediate)[]): MachineState | ||
/* General Types */ | ||
export type ContextFunction<T> = (initialContext: T) => any | ||
export type ContextFunction<T> = (initialContext: T) => T | ||
@@ -105,0 +119,0 @@ export type GuardFunction<C, E> = (context: C, event: E) => boolean |
{ | ||
"name": "robot3", | ||
"version": "0.2.18", | ||
"version": "0.2.19", | ||
"description": "A function, immutable Finite State Machine library", | ||
@@ -5,0 +5,0 @@ "main": "dist/machine.js", |
@@ -1,3 +0,11 @@ | ||
# 🤖 Robot | ||
# Robot | ||
<p align="center"> | ||
<img | ||
alt="The Robot logo, with green background." | ||
src="https://github.com/matthewp/robot-logo/raw/master/logo/robot-green.png" | ||
width="40%" | ||
/> | ||
</p> | ||
A small functional and immutable Finite State Machine library. Using state machines for your components brings the declarative programming approach to application state. | ||
@@ -4,0 +12,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23086
538
48