Socket
Socket
Sign inDemoInstall

val-state

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

val-state

State management with value-enhancer.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
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$.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$.increment();

FAQs

Package last updated on 13 Feb 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc