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 - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

package.json
{
"name": "flux-commons-store",
"version": "0.0.3",
"version": "0.0.4",
"description": "Base Store class to use with Flux/Dispatcher",

@@ -5,0 +5,0 @@ "main": "dist/store.js",

# Flux Commons Store
Base Store class to use with Flux/Dispatcher from Facebook. The idea is to have a clean
and simple API to interact with the Facebook Dispatcher and register handlers.
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
```js
var Store = require('flux-commons').Store;
var Store = require('flux-commons-store');
var appDispatcher = require('./app_dispatcher');

@@ -30,17 +32,14 @@ var Actions = require('./actions');

## Matchers
### Custom matchers
```js
listenToActionWithTags (tags, handler, deferExecution) {
if (! (tags instanceof Array)) {
tags = [tags];
}
var matcher = function(action, params) {
var matchedTagsCount = _.intersection(action.tags, tags).length;
return matchedTagsCount === tags.length;
};
function matcher(action, params) {
return params.response.status === 401;
}
this.listenToMatchingAction(matcher, handler, deferExecution);
}
myStore.listenToMatchingAction(matcher, handleUnauthorized);
function handleUnauthorized() { ... } // Delete the token or any other aciton required by your App.
```
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