{"id":25996,"library":"nl-flux","title":"nl-flux","description":"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.","status":"active","version":"1.1.10","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/nitrogenlabs/nl-flux","tags":["javascript","nitrogenlabs","flux"],"install":[{"cmd":"npm install nl-flux","lang":"bash","label":"npm"},{"cmd":"yarn add nl-flux","lang":"bash","label":"yarn"},{"cmd":"pnpm add nl-flux","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for immutable state management within stores; required for Store operations.","package":"immutable","optional":false}],"imports":[{"note":"CommonJS require does not work with ES6 default export; use named import instead.","wrong":"const Flux = require('nl-flux')","symbol":"Flux","correct":"import { Flux } from 'nl-flux'"},{"note":"Store is a named export; destructure from the module.","wrong":"const Store = require('nl-flux').Store","symbol":"Store","correct":"import { Store } from 'nl-flux'"},{"note":"The package uses named exports, not a default export. Use namespace import or named imports.","wrong":"import NLFlux from 'nl-flux'","symbol":"default import","correct":"import * as NLFlux from 'nl-flux'"}],"quickstart":{"code":"import { Flux, Store } from 'nl-flux';\nimport { Map } from 'immutable';\n\nclass AppStore extends Store {\n  initialState() {\n    return { count: 0 };\n  }\n\n  onAction(type, data, state) {\n    switch (type) {\n      case 'INCREMENT':\n        return state.update('count', v => v + 1);\n      default:\n        return state;\n    }\n  }\n}\n\nconst store = Flux.registerStore(AppStore);\n\nFlux.dispatch({ type: 'INCREMENT' });\nconsole.log(Flux.getStore('AppStore').toJS()); // { count: 1 }","lang":"javascript","description":"Demonstrates creating a Store with initial state, handling actions via onAction, registering with Flux, dispatching an action, and reading the immutable state tree."},"warnings":[{"fix":"Ensure the store class is registered via Flux.registerStore and the name matches the class name used in getStore.","message":"Flux.getStore('storeName') assumes store is registered with that name (the class name). If not, it may return undefined.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always return state in each case of onAction, even if no change: return state.","message":"onAction switch must return new state or the same state. Not returning a value may lead to unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure immutable version is compatible; test with immutable@3.x if issues arise.","message":"Immutable.js v4 changed Map API (e.g., fromJS). Older versions may fail with nl-flux.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'import { Flux } from 'nl-flux'' and then 'Flux.getStore('storeName')'.","cause":"Flux.getStore is the correct method; ensure you import Flux correctly and it is not shadowed.","error":"TypeError: flux.getStore is not a function"},{"fix":"Use 'import { Store } from 'nl-flux'' instead of 'import Store from 'nl-flux''.","cause":"Store is a named export, not a default export.","error":"Store is not a constructor"},{"fix":"Check that the store is registered with Flux.registerStore(MyStore) and use the same name in getStore (defaults to class name).","cause":"getStore returned undefined because the store name is incorrect or not registered.","error":"Cannot read property 'toJS' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}