🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@trinitymirrordigital/state-manager

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trinitymirrordigital/state-manager

Managing state in web components

latest
Source
npmnpm
Version
1.5.0
Version published
Weekly downloads
11
1000%
Maintainers
2
Weekly downloads
 
Created
Source

@trinitymirrordigital/state-manager

For managing state in ET web components

Usage

import { State } from '@trinitymirrordigital/state-manager';


// Basic set up - pass keys you want to track.
const state = StateManager(['foo']); // will track changes to foo
// or you can pre-assign values
const state = StateManager(['foo'], {foo: 'bar'}); // will track changes to foo

// Add observer which will be called when there is a change to foo
state.addObserver = (state, oldState)=>{
  // do something with change
}

// basic usage
state.foo = 'something'; // add observer called 
// observer called with state {foo: 'something'} and oldState {foo: 'bar'}

state.foo = 'something'; // observer not called

// mass assign
state.massAssign = { foo: 'something else'}
// observer called with state {foo: 'something else'} and oldState {foo: 'something'}

// Get state
state.getState // return { foo: 'something else'}


FAQs

Package last updated on 22 Oct 2020

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