kenkunz / svelte-fsm

Tiny, expressive finite state machines for svelte
MIT License
275 stars 9 forks source link

Svelte FSM

Svelte FSM logo

A tiny, simple, expressive, pramgmatic Finite State Machine (FSM) library, optimized for Svelte.

Quick Start

Installation

npm install svelte-fsm

Create your first FSM and use it in a Svelte component

<script>
  import fsm from 'svelte-fsm';

  const simpleSwitch = fsm('off', {
    off: { toggle: 'on' },
    on: { toggle: 'off' }
  });
</script>

<button value={$simpleSwitch} on:click={simpleSwitch.toggle}>
  {$simpleSwitch}
</button>

Usage Overview

Svelte FSM's API is delightfully simple. FSM constructs are intuitively mapped to core JavaScript language features, resulting in a highly expressive API that's effortless to remember, a joy to write, and natural to read.

Next Steps

Svelte Summit video


Contributors