
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
flux-store-base
Advanced tools
Yet another store utility for flux.
flux-store-base is superseded by floox which, apart form the shorter name, introduces a few new boilerplate reductions and a simple solution for circular dependency of stores.
It won't be maintained anymore.
Install the package with this command:
npm install flux-store-base --save
Then you can require the package with require('flux-store-base'). Once you do that, you get two functions:
Store(dispatcher, config) constructor configures the store using the provided flux dispatcher and config, which is an object whose methods and properties will be assigned to the resulting store.
There are also some things going under the hood, but more about that below (see: Features).
inject(dispatcher) returns a constructor which can be used to create stores without passing dispatcher every time. The resulting function has only one argument - config.
Action creator:
function createSomeAction(someData) {
AppDispatcher.dispatchSomeAction(someData);
}
Store:
var Store = require('flux-store-base').Store;
var AppDispatcher = require('../dispatcher');
var MyFunkyStore = new Store(AppDispatcher, {
displayName: 'MyFunkyStore',
events: ['theChange'],
getSomething() {
return this.something;
},
onSomeAction(someData) {
this.something = someData;
this.emit('theChange');
},
});
Component:
var React = require('react');
var MyFunkyStore = require('./path-to-my-funky-store');
var MyFunkyComponent = React.createClass({
componentDidMount() {
MyFunkyStore.on('theChange', this.doSomething);
},
componentWillUnmount() {
MyFunkyStore.off('theChange', this.doSomething);
},
doSomething() {
// Set state or whatever. You know what to do.
},
});
Create a file (suggested name: base.js, contained in the store directory):
var fluxStoreBase = require('flux-store-base');
var AppDispatcher = require('../dispatcher');
var Store = fluxStoreBase.inject(AppDispatcher);
module.exports = Store;
Now you can use the module like this, without requiring the dispatcher for each store:
var Store = require('./base');
var MyFunkyStore = new Store({
...
});
The property displayName is used for errors. If it is absent, displayName will be 'anonymous'.
Each method in the config which starts with "on" and a capital letter, e. g. "onSomeAction" will be treated as an action handler.
That means:
If any action handlers are detected ("on-" methods), the store will be registered in the dispatcher and will have a dispatchToken property added. It can be then used like this:
AppDispatcher.waitFor([VeryFineStore.dispatchToken]);
There are two properties on config that can be used to configure events to which components can subscribe: events and maxListeners.
events is expected to be an array of strings (but can be left undefined).
Each of those strings is then used to construct three methods for the resulting store: emitter, subscriber and unsubscriber.
For event name 'theChange' we will get emitter emitTheChange, subscriber addTheChangeListener and
unsubscriber removeTheChangeListener. As you can see, the name of the event is capitalized and incorporated into the new methods' names.
The emitter has no arguments - you should retrieve the data only from the store. Subscriber and unsubscriber have one argument - event handler.
Also, methods emit(event), on(event, fn) and off(event, fn) will be added to the store.
In lieu of a formal styleguide, take care to maintain the existing coding style.
Copyright (c) 2015 FatFisz. Licensed under the MIT license.
FAQs
Yet another store utility for flux
We found that flux-store-base demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.