Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

straightforward-statejs

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

straightforward-statejs

Straightforward StateJS, with conditional watching

  • 1.0.0
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Straightforward State

A state object that is conditionally watchable on first depth only.

Install:

npm i -s straigtforward-state

or

yarn add straigtforward-state

import or require

import state from "straightforward-state";

or

const state = require("straightforward-state");

Initialize

state.set = { things: [1,2,3], others: [3,4,5], numberOfThings: 6 };

or

state.set({ things: [1,2,3], numberOfThings: 3 });

Access

Access values as usual

state.things // [1,2,3]
state.numberOfThings // 3

Set

Set the state properties as usual. When set watchers will be run, mutations does not trigger however, like pushing to an array value.

state.things = [...state.things, 4];

Watch

state.watch.things = (val, was) => {
  val // [1,2,3,4]
  state.things // [1,2,3,4]

  state.numberOfThings = state.things.length;
};

state.watch.numberOfThings((val, was) => {
  val // 4
  was // 3
});

FAQs

Package last updated on 20 Mar 2022

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