0.0.15 • Published 1 year ago

@olympos/soteria v0.0.15

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago