Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flux-commons-store

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flux-commons-store

Base Store class to use with Flux/Dispatcher

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Flux Commons Store

The missing Store class to use with facebook/flux Dispatcher (https://github.com/facebook/flux).

  • NO string matching (no more switch/case with huge constants file full of strings)
  • Smart matching, define one handler and match in a generic fashion multiple actions. (i.e: If ANY 402 status code then do something)

Usage

var Store = require('flux-commons-store');
var appDispatcher = require('./app_dispatcher');
var Actions = require('./actions');

class MyStore extends Store {
  getItems() {...}
}

var myStore = new MyStore(appDispatcher);

myStore.listenToAction(Actions.fetchItems, handleFetchItems);
myStore.listenToAction(Actions.fetchItems.done, handleFetchItemsDone);
myStore.listenToAction(Actions.fetchItems.fail, handleFetchItemsFail);

function handleFetchItems() { ... } // i.e: Set a flag as loading
function handleFetchItemsDone() { ... } // i.e: Store the list
function handleFetchItemsFail() { ... } // i.e: Show error message

module.exports = myStore;

Custom matchers


function matcher(action, params) {
  return params.response.status === 401;
}

myStore.listenToMatchingAction(matcher, handleUnauthorized);

function handleUnauthorized() { ... } // Delete the token or any other aciton required by your App.

Keywords

FAQs

Package last updated on 02 Feb 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc