Browse guides

Organize state transitions with FluxStore

Model application changes as named Flux transitions.

The counter example applies `increment` and renders `Count: 2`; asynchronous actions and calculated values remain in the same state model.

Table of contents

Main APIs

FluxStore
Provides named mutations, asynchronous actions, computed getters, modules and plugins over Flux state.
ts
import { mount } from "valyrian.js";
import { FluxStore } from "valyrian.js/flux-store";

const store = new FluxStore({
  state: { count: 0 },
  mutations: {
    increment(state, amount = 1) {
      state.count += amount;
    },
  },
});

store.commit("increment", 2);

mount("body", () => `Count: ${store.state.count}`);

Exact references