Coder Social home page Coder Social logo

state-containers's Introduction

state-containers

  • Strongly typed state containers with TypeScript.
  • Redux-like but without the boilerplate.
  • Simple state management for your services and React apps.
  • Composable: use just state containers, or with React helpers or add optional routines to the mix.

Usage

Install

npm install state-containers

Use

import {StateContainer, PureTransition, createStateContainer} from 'state-containers';

type CounterState = number;

interface CounterPureTransitions {
  increment: PureTransition<CounterState, [number]>;
  double: PureTransition<CounterState, []>;
  setTo: PureTransition<CounterState, [number]>;
}

const defaultState: CounterState = 0;

const pureTransitions: CounterPureTransitions = {
  increment: (cnt) => (by) => cnt + by,
  double: (cnt) => () => 2 * cnt,
  setTo: (ctn) => (to) => to,
};

const store = createStateContainer(defaultState, pureTransitions);

store.transitions.increment(5);
store.transitions.double();
store.state; // 10

Reference

Examples

License

Unlicense โ€” public domain.

state-containers's People

Contributors

renovate-bot avatar renovate[bot] avatar semantic-release-bot avatar streamich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

state-containers's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: RepoCacheS3.read() - failure

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency pretty-quick to v3.3.1
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency pretty-quick to v4
  • chore(deps): update node.js to v20
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
  • node 10.24
npm
package.json
  • fast-deep-equal ^3.1.1
  • react-use ^13.9.0
  • @semantic-release/changelog 5.0.1
  • @semantic-release/git 9.0.0
  • @semantic-release/npm 7.1.1
  • @types/jest 26.0.24
  • husky 6.0.0
  • jest 26.6.3
  • prettier 2.8.8
  • pretty-quick 3.1.3
  • react 18.2.0
  • react-dom 18.2.0
  • rimraf 3.0.2
  • rxjs 7.8.1
  • semantic-release 17.4.2
  • ts-jest 26.5.6
  • ts-node 9.1.1
  • tslint 5.20.1
  • tslint-config-common 1.6.2
  • typescript 4.1.5
  • react *
  • rxjs *

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.