@vanyamate/sec
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

SEC (Store, Effect, Combine)

Tiny state manager

npm i @vanyamate/sec
import { store, effect, combine } from './index';


const sum = async (a, b) => a + b;

// Create effect
const sumEffect = effect(sum);

// Create stores
const allSums = store(0).on(sumEffect, 'onSuccess', (state, { result }) => state + result);
const lastSum = store(0).on(sumEffect, 'onSuccess', (_, { result }) => result);

// Create combine
const bothSum = combine([ allSums, lastSum ], (...args) => args.reduce((acc, item) => acc + item.get(), 0));

Readme

Keywords

Package Sidebar

Install

npm i @vanyamate/sec

Weekly Downloads

3

Version

0.1.1

License

ISC

Unpacked Size

8.09 kB

Total Files

4

Last publish

Collaborators

  • vanyamate