0.0.15 • Published 11 months ago

@olympos/soteria v0.0.15

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Soteria - Reactive Finite State Machine

Soteria is a lightweight, object-oriented reactive finite state machine implementation in Javascript. Soteria builds upon the functionality of Soter and exposes a new reactive mixin. Soteria uses @vue/reactivity under the hood.

Installation

npm install @olympos/soteria

Quickstart

Here is a simple example of how to leverage Soteria:

import { addReactiveStateMachine } from "@olympos/soteria";
import { computed, ref } from "@vue/reactivity";

// Create a composable
const useMatter = (s: string) => {
  const state = s;
  const temperature = ref(0);

  const canMelt = computed(() => {
    return temperature.value > 40;
  });

  return {
    state,
    temperature,
    canMelt,
  };
};
// Merge composable instance with state machine
const matter = addReactiveStateMachine(useMatter("solid"), {
  melt: { origins: "solid", destination: "liquid", conditions: "canMelt" },
});

console.log(matter.state); // solid
const { temperature } = matter;
temperature.value = 50;
console.log(matter.state); // liquid
0.0.15

11 months ago

0.0.12

11 months ago

0.0.13

11 months ago

0.0.14

11 months ago

0.0.10

11 months ago

0.0.11

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago