Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
flux-commons-store
Advanced tools
Tested, Modular and Small Flux Store class to use with facebook/flux Dispatcher (https://github.com/facebook/flux).
Migrate from the default proposed 'string' comparison approach:
switch(action.actionType) {
case TodoConstants.TODO_CREATE:
break;
case TodoConstants.TODO_DESTROY:
break;
default:
return true
}
to a simpler and more scalable api like:
// Async actions
myStore.listenToAction(Actions.fetchItems, handleFetchingItems);
myStore.listenToAction(Actions.fetchItems.done, handleFetchingItemsDone);
myStore.listenToAction(Actions.fetchItems.fail, handleFetchingItemsFail);
// Generic matchers
var unauthorizedMatcher = (payload) => payload.params.response.status === 401;
myStore.listenToMatchingAction(unauthorizedMatcher, handleUnauthorized);
Also provide the suger needed for listening/emiting changes.
The Store class expects a 'Dispatcher' on construction time, being the Dispatcher either the facebook/flux one or a custom one respecting the same interface. (more details, on how to use your own, later). new Store(dispatcher)
Actions. Actions can be anything, the store provides a default impl where it checks for a property 'action' inside the payload to perform the matching, by doing strict equality. However you can just send a 'String' to the dispatch and it will work too.
(Check the store.js docs for full explanation and complete API)
.listenToAction(action, handler)
action
any js objcet that will be compared with the payload.action
object by strict equality.handler
the function to execute when there is a 'match', handler(payload, setSilent)
.listenToMatchingAction(matcher, handler)
matcher
a function on the way matcher(payload)
. The store will check each dispatched payload with this matcher and execute the handler only when the matcher returns true..dispatcherToken()
.addChangeListener(cb) .removeChangeListener(cb) .emitChange()
https://gist.github.com/rafaelchiti/915c680b4713c459026d
For more details please check the tests and the store.js
the code is very simple and self explanatory (hopefully).
FAQs
Base Store class to use with Flux/Dispatcher
The npm package flux-commons-store receives a total of 0 weekly downloads. As such, flux-commons-store popularity was classified as not popular.
We found that flux-commons-store 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.