0.1.0-beta.14 • Published 4 years ago

@lauf/lauf-store v0.1.0-beta.14

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

State Management for Javascript with Typescript support.

codecov

Lauf Store

Logo - Diego Naive, Noun Project.

@lauf/lauf-store provides a minimal reactive state-management solution, a simple substitute for Flux/Redux based on Immer.

It is incredibly lightweight and suitable for adoption with almost any server-side or client-side framework in Typescript or Javascript.

Browse the API or see the minimal Typescript example inlined below without React, showing how to define a new application state, track changes and make edits.

A React binding of @lauf/lauf-store is provided by the @lauf/lauf-store-react package.

import { createStore, Immutable } from "@lauf/lauf-store";

// Define a type for Store state
export interface AppState {
  color: [number, number, number];
}

// Define the initial Store state
const INITIAL_STATE: Immutable<AppState> = {
  color: [0, 0, 0],
} as const;

// Create and initialize a store
const store = createStore(INITIAL_STATE);

// Watch for changes
store.watch(console.log);

// Change the color - this will automatically call console.log and print the modified app state
store.edit((draft) => {
  draft.color = [255, 0, 0];
});

Visit @lauf/lauf-store-react to learn about useSelected() which can refresh React components when only a selected part of your state changes.

0.1.0-beta.14

4 years ago

0.1.0-beta.13

4 years ago

0.1.0-beta.12

4 years ago

0.1.0-beta.10

4 years ago

0.1.0-beta.11

4 years ago

0.1.0-beta.9

4 years ago

0.1.0-beta.8

4 years ago

0.1.0-beta.7

4 years ago

0.1.0-beta.5

4 years ago

0.1.0-beta.4

4 years ago

0.1.0-beta.6

4 years ago

0.1.0-beta.2

4 years ago

0.1.0-beta.1

4 years ago