0.1.0 ā€¢ Published 2 years ago

@babichjacob/finite v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

This library for Svelte is just a small wrapper around the excellent svelte-fsm with small design tweaks to my taste.

šŸ’» Installation

npm install --save-dev @babichjacob/finite

šŸ›  Usage

Import the finite state machine creating function from @babichjacob/finite and use it just like svelte-fsm, except with the additional __auto helper and implicitly use the first state listed as the initial one:

<script>
  import finite from "@babichjacob/finite";

  /** @param {number} ms */
  const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

  const traffic = finite({
    green: {
      async __auto() {
        await wait(5_000);
        return "yellow";
      },
    },

    yellow: {
      async __auto() {
        await wait(2_000);
        return "red";
      },
    },

    red: {
      async __auto() {
        await wait(5_000);
        return "green";
      },
    },
  });
</script>

<div style:background-color={$traffic}>{$traffic}</div>

šŸ˜µ Help! I have a question

Create an issue and I'll try to help.

šŸ˜” Fix! There is something that needs improvement

Create an issue or pull request and I'll try to fix.

šŸ“„ License

MIT

šŸ™ Attribution

This README was generated with ā¤ļø by readme-md-generator

0.1.0

2 years ago

0.0.3

2 years ago