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

redux-store-controller

v2.0.1

Published

Storage for object structure data with subscribing for changes in fields of this data

Readme

redux-store-controller


npm version GitHub license build status dependencies Status devDependencies Status

Storage for object structure data with subscribing for changes in fields of this data. Current solution based on redux data storing logic and implemented on the lodash

Installation

npm i -S redux-store-controller

Quick start

// Calling an instance of the storage class
import Stores from "redux-store-controller";

// State storage provides an object data structure
// Now you can set values for the storage state
Stores.set({ data: { field: "value"}})

// Or you can specify the value of a specific field. 
// In this case, the missing structure of the parent fields will be created automatically
Stores.setField("data.field", "new value");


// You have the ability to monitor the status of storage fields

// To subscribe to changes, use the .watch() method, as arguments, 
// you must specify the structural path to the field, in the string format, 
// and the callback function that will be called whenever the value specified for the field, 
// which as first argument changes,  and / or its child fields
const cb = value => { console.log(value) };
const unWatch = Stores.watch("data.field", cb);

// The callback function as an input parameter will get the value of the field (of all its contents) 
// to which you made a subscription


// To cancel a subscription, use:
unWatch();

Inherit subscription classes

These classes implement the synchronization of the state of the storage and own state by subscription to changes, through the rules obtained in the arguments of the class constructor.

A set of rules consists of an array of objects which has obligatory key name "field" with path to field in string type.

If we have next data in Storage state:

{
  "data": { "field": "value" }
}

For subscribe on value changes in field "data.field", use follow rule:

{
  rules: [{ field: "data.field" }]
}

Also you need insert instance of Storage in inheritance class constructor argument.

ControllerStateStore

import Stores from "redux-store-controller";
import ControllerStateStore from "redux-store-controller/controllerStateStore";

export default class TestController extends ControllerStateStore {
  constructor() {
    const options = {
      stores: Stores,
      rules: [{ field: "data.field" }]
     };
    super(options);
  }
	
  stateDidUpdate() {
    console.log(this.state);
  }
}

We have redefined the method of the inherited ControllerStateStore class stateDidUpdate().

Which are called by internal logic of class ControllerStateStore for all subsequent changes in subscribed fields.

Not forget about opportunity into ES2015 provides a default class constructor if one is not specified. As such, it is unnecessary to provide an empty constructor or one that simply delegates into its parent class.

// FILE: testController.js
import ControllerStateStore from "redux-store-controller/controllerStateStore";

export default class TestController extends ControllerStateStore {
  stateDidUpdate() {
    console.log(this.state);
  }
}
import Stores from "redux-store-controller";
import TestController from "./testController";

const options = {
  stores: Stores,
  rules: [{ field: "data.field" }, { field: "data.fieldSecond" }]
};

const controller = new TestController(options);

console.log(controller.state); 
// { 
//   "data.field": "value", 
//   "data.fieldSecond": "second value" 
// }

ComponentStateStore

The internal logic of the ComponentStateStore class is identical to the ControllerStateStore with differences, due to the adaptation of this class for use as a React Component.

import Stores from "redux-store-controller";
import ComponentStateStore from "redux-store-controller/componentStateStore";
import { createElement } from "react"

export default class TestController extends ComponentStateStore {
  constructor() {
    const options = {
      stores: Stores,
      rules: [{ field: "data.field" }]
     };
    super(options);
  }
	
  render() {
    return createElement("h1", null, this.state["data.field"]);
  }
}