npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@plancky/state

v0.1.1

Published

Handling asyncronosities has always been a pain in state management libraries. Even with redux middleware like thunk it's still hard to work with async event listeners and clean them up in a safe way. I decided to create a new state management library tha

Readme

A state management library with built-in effects support

Handling asyncronosities has always been a pain in state management libraries. Even with redux middleware like thunk it's still hard to work with async event listeners and clean them up in a safe way. I decided to create a new state management library that can handle effects inherently. You can find my thought process of creating the package in this article Building a React state management library with built in effects support.

Basic example

import createStore from '@plancky/state';

const store = createStore(
  { username: 'Erik' },
  ({ setState }) => ({
    setUsername: (username) => {
      setState(s => ({ username }));
    }
  })
);

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

store.setUseranem('George'); // Logs { username: "George" }

Advanced example

import createStore from '@plancky/state';

const store = createStore(
  { messages: [] },
  ({ setState, addEffect, removeEffect }) => ({
    startChat: () => {
      addEffect('my_chat', () => {
        const intRef = setInterval(() => {
          setState(s => ({ messages: [...s.messages, 'new_msg']}));
        }, 1000);
        return () => clearInterval(intRef);
      });
    },
    stopChat: () => {
      removeEffect('my_chat');
    }
  })
);

store.actions.startChat(); // The state will be update with an additional message every second

// ... some time later ...

store.actions.stopChat(); // The store will no longer be updated by the effect

API

createStore

The createStore function takes 2 arguments. The first argument is the initial state of the store. The second argument is a function to initialize your actions. This function gets passed an object with properties getState, setState, addAction and removeAction. createStore returns a store object.

getState

getState is a function which gets the current state of the store. It can either be called with store.getState or in an acttion with the utility properties provided to the action creator function (2nd argument of createStore).

setState

setState is a function which changes the state and informs all the listeners about the change. It can ither be called with store.setState or in an action with the utility properties provided to the action creator function (2nd argument of createStore).

addEffect

addEffect is the idiomatic way to create effects in @plancky/state. It takes 2 arguments - the id of the effect, and the effect itself. An effect is a funtion which starts an async task (event listener, setInterval, etc.) and returns a cleanup function. For example:

addEffect('my_effect', () => {
  const intRef = setInterval(() => {
    console.log('hello');
  }, 1000);
  return () => clearInterval(intRef);
});

Now the effect with id "my_effect" will be initialized and "hello" will be logged every second. The addEffect funciton can be called with store.addEffect or in an action with the utility properties provided to the action creator function (2nd argument of createStore).

If you attempt to create an effect with the same id - an error will be thrown.

removeEffect

removeEffect cleans up an already initialized effect with it's id. Following up on the previous example:

removeEffect('my_effect');

Now the effect with id "my_effect" is cleaned up. "hello" will no longer be logged to the console. The removeEffect funciton can be called with store.removeEffect or in an action with the utility properties provided to the action creator function (2nd argument of createStore).

store.actions

store.actions is the object containing all the actions returned from the action creator function (2nd argument of createStore).

store.subscribe

store.subscribe takes a callback which is called every time the store is changes (by setState). Hook into store.subscribe to react to state changes.