
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
simple-shared-state
Advanced tools
Easily share state between components using a no-frills observable object API
Redux is verbose. SimpleSharedState is brief.
SimpleSharedState is still relatively experimental. Versions are following semver, but the version being greater than 1.0 doesn't mean it's considered production ready just yet. Please review the project source and tests to determine if it's viable for your project. More elaborate tests are needed to test SimpleSharedState performance against Redux.
npm install simple-shared-state
If using script tags:
<script src="https://unpkg.com/simple-shared-state"></script>
<script>
const store = new SimpleSharedState.Store({});
</script>
Use dist/simple-shared-state.es5.umd.js. For example:
<script src="https://unpkg.com/simple-shared-state/dist/simple-shared-state.es5.umd.js"></script>
First create a store.
import { Store } from "simple-shared-state";
const initialState = {
user: {
name: "Alice",
slogan: "simple-shared-state makes apps fun again",
},
};
const actions = () => ({
changeSlogan: (newSlogan) => ({
user: {
slogan: newSlogan,
},
}),
});
const store = new Store(initialState, actions);
Then create a watcher. Don't worry about error handling in selectors, just return the state that you want.
const selector = (state) => state.user;
store.watch(selector, (state) => {
console.log("user snapshot:", state);
});
Then call your action to update state and trigger the watch handler.
store.actions.changeSlogan("simple-shared-state is better than cat memes");
// 'user snapshot:' { name: 'Alice', slogan: 'simple-shared-state is better than cat memes' }
Works with devtools, of course. Just pass in the reference like this:
const store = new Store(initialState, actions, window.__REDUX_DEVTOOLS_EXTENSION__);
FAQs
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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.