Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 29, 2021 04:18 pm GMT

Dead simple State Management with Stoxy

What

Stoxy is a new, modern, reactive state management system for web applications.

It's a small, dependencyless, extensible set of functions to create stateful features for you web app, and even persist them through sessions.

How

Stoxy requires no setup. After the install with

npm install @stoxy/core

You don't need to hassle with reducers, nor any initial state objects, you can immediately start writing stateful applications.

import { write } from '@stoxy/core';const userData = {    userName: "Stoxy",    shoppingCart: [        { id: 123, name: "Flaming hot cheetos" }    ],    shoppingHistory: {        latestProducts: [            { id: 555, name: "Doritos" },            { id: 958, name: "Pringles" }        ]    }};write("userData", userData);

Persisting objects through sessions can be done on a per-key basis with a single command

import { persistKey } from '@stoxy/core';persistKey('userData');

Reading data through the promise based API is made simple too:

read('shoppingcart').then(shoppingCartItems => {    shoppingCartItems.map(item => console.log(item));});

There are multiple user-tailored functions at your disposal for more specific actions too. Read more about them at the docs.

Where

Stoxy can be run anywhere, with any framework. Even with no framework at all.

Currently Stoxy ships with element mixins for Web Components and hooks for React/Preact.

Read more about Stoxy at the site: Stoxy.dev

Stoxy just reached 50 stars in Github. Join the stargazers at GitHub!


Original Link: https://dev.to/matsuuu/dead-simple-state-management-with-stoxy-41pg

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To