New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@axcraft/external-state

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
Package was removed
Sorry, it seems this package was removed from the registry

@axcraft/external-state

Data container allowing for subscription to its updates

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

@axcraft / External State

A lightweight data container allowing for subscription to its updates, e.g. to be shared by multiple independent parts of code

Such containers can be used as state shared across application components with libraries like React. See @axcraft/react-external-state exposing a ready-to-use hook for shared state management.

Initialization

ExternalState accepts data of any kind.

import { ExternalState } from "@axcraft/external-state";

// With a primitive value
let state1 = new ExternalState(0);

// With a nonprimitive value
let state2 = new ExternalState({ counter: 0 });

Value manipulation

The ExternalState value can be read and updated with getValue() and setValue(update). setValue(update) accepts either a new value or a function (value) => nextValue that returns a new state value based on the current state value.

let state = new ExternalState({ counter: 0 });

state.setValue({ counter: 100 });
state.setValue((value) => ({ ...value, counter: value.counter + 1 }));

let value = state.getValue();
console.log(value.counter); // 101

Subscription to updates

Each time the ExternalState value is updated via setValue(value) the state emits an "update" event allowing for subscriptions:

let unsubscribe = state.on("update", ({ current, previous }) => {
  console.log(current, previous);
});

Each subscription returns an unsubscription function. Once it's invoked, the given callback is removed from the ExternalState instance and no longer called when the state is updated.

Keywords

state

FAQs

Package last updated on 24 Feb 2026

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