Socket
Socket
Sign inDemoInstall

val-state

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    val-state

State management with value-enhancer.


Version published
Weekly downloads
7
increased by16.67%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

val-state

Build Status npm-version Coverage Status minified-size

Commitizen friendly Conventional Commits code style: prettier

State management with value-enhancer.

Install

npm add val-state value-enhancer

Usage

import { createStore } from "val-state";

const store$ = createStore({
  count: 0,
});

store$.subscribe(state => {
  console.log(state);
});

Create store with actions:

import { createStore } from "val-state";

const store$ = createStore(
  {
    count: 0,
  },
  state$ => ({
    increment: (step = 1) => {
      state$.set({ count: state$.value.count + step });
    },
  })
);

store$.subscribe(state => {
  console.log(state);
});

store$.act.increment();

Assign actions to normal val:

import { val } from "value-enhancer";
import { assignActions } from "val-state";

const state$ = val({ count: 1 });

const store$ = assignActions(state$, {
  increment: (step = 1) => {
    state$.set({ count: state$.value.count + step });
  },
});

assert(store$ === state$);

store$.act.increment();

Keywords

FAQs

Last updated on 16 Feb 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc