Registry / web-framework / nl-flux

nl-flux

JSON →
library1.1.10jsnpmunverified

An ES6 Flux library for ReactJS, providing a Flux dispatcher and Store base class with an immutable state tree. Version 1.1.10 (latest stable) includes core Flux and Store exports, plus sessionStorage helpers. The library emphasizes an Action-on-Store pattern with Immutable.js state management, offering event listeners on store updates. Requires Immutable.js as a peer dependency. Compared to alternatives like Redux, nl-flux is more opinionated and tightly coupled with Immutable.js, making it suitable for projects already using Immutable. Releases appear infrequent; check for compatibility with newer React versions.

npm install nl-flux
INSTALL
IMPORT
SIG · NL-FLUX
N
nl-flux
web-frameworkjavascriptv1.1.10
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Flux
import { Flux } from 'nl-flux'
const Flux = require('nl-flux')
CommonJS require does not work with ES6 default export; use named import instead.
Store
import { Store } from 'nl-flux'
const Store = require('nl-flux').Store
Store is a named export; destructure from the module.
default import
import * as NLFlux from 'nl-flux'
import NLFlux from 'nl-flux'
The package uses named exports, not a default export. Use namespace import or named imports.

Demonstrates creating a Store with initial state, handling actions via onAction, registering with Flux, dispatching an action, and reading the immutable state tree.

import { Flux, Store } from 'nl-flux'; import { Map } from 'immutable'; class AppStore extends Store { initialState() { return { count: 0 }; } onAction(type, data, state) { switch (type) { case 'INCREMENT': return state.update('count', v => v + 1); default: return state; } } } const store = Flux.registerStore(AppStore); Flux.dispatch({ type: 'INCREMENT' }); console.log(Flux.getStore('AppStore').toJS()); // { count: 1 }
Debug
Known issues
gotchaFlux.getStore('storeName') assumes store is registered with that name (the class name). If not, it may return undefined.
fix
Ensure the store class is registered via Flux.registerStore and the name matches the class name used in getStore.
affects: >=1.0.0
gotchaonAction switch must return new state or the same state. Not returning a value may lead to unexpected behavior.
fix
Always return state in each case of onAction, even if no change: return state.
affects: >=1.0.0
breakingImmutable.js v4 changed Map API (e.g., fromJS). Older versions may fail with nl-flux.
fix
Ensure immutable version is compatible; test with immutable@3.x if issues arise.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: flux.getStore is not a function
Flux.getStore is the correct method; ensure you import Flux correctly and it is not shadowed.
fix
Use 'import { Flux } from 'nl-flux'' and then 'Flux.getStore('storeName')'.
Store is not a constructor
Store is a named export, not a default export.
fix
Use 'import { Store } from 'nl-flux'' instead of 'import Store from 'nl-flux''.
Cannot read property 'toJS' of undefined
getStore returned undefined because the store name is incorrect or not registered.
fix
Check that the store is registered with Flux.registerStore(MyStore) and use the same name in getStore (defaults to class name).
Upgrade
Version history
1.1.10latest on npm
Audit
Dependencies
immutablerequiredUsed for immutable state management within stores; required for Store operations.
Agent activity
4 hits · last 30 days
node
4
Resources
nl-flux — npm install nl-flux · libregistry