About Matchina
What is Matchina?
Section titled “What is Matchina?”Matchina is a TypeScript-first, lightweight toolkit for building type-safe state machines, with powerful pattern matching and async handling. It provides:
- Strongly-typed state machines with full type inference
- Tagged unions via the
matchbox
pattern for discriminated types - Type-safe transitions with smart parameter inference
- Promise integration for handling async operations safely
- Nano-sized, opt-in primitives for state machines and async logic
- Composable APIs that work together or standalone
Why Matchina?
Section titled “Why Matchina?”- Lightweight: Each feature is just a few hundred bytes
- TypeScript-First: Full type inference and safety
- Composable: Use only what you need
- No Dependencies: Zero runtime dependencies
- React Integration: First-class support for React
Type Safety and Inference
Section titled “Type Safety and Inference”On states
Section titled “On states”- Factory autocompletes
states
types - State Creator autocompletes parameters
- State autocompletes
key
- State autocompletes
data
match
autocompletes state typesmatch
handler autocompletes state properties
On state machines
Section titled “On state machines”- transition config autocompletes state keys
- transition config autocompletes transition type and from properties
- autocomplete available states
- api autocompletes state types
- api autocompletes transition params
On state machine events
Section titled “On state machine events”event
autocompletes eventtype
,to
,from
, andparams
event.match
autocompletes event typeevent.match
handler autocompletes event params- type assert matching
to.key
,from.key
and eventtype
What’s inside
Section titled “What’s inside”- Matching: switch and filter matching, union factories
- State Machines: state machine, promise machine
- Extensibility: composable setup, enhancers, lifecycle
- Extras: when, delay, effects, subscribe, reset
- Integrations: React