
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@brainstack/state
Advanced tools
@brainstack/state
A module for managing application state.
To install this module, run the following command:
npm install @brainstack/state
To use this module, import the createState function and the State interface from the module:
import { createState, State } from '@brainstack/state';
interface AppState {
count: number;
}
const initialState: AppState = {
count: 0,
};
const state: State<AppState> = createState(initialState);
state.mutate(currentState => {
return { ...currentState, count: currentState.count + 1 };
});
console.log(state.getState());
createState(initialState: T): State Creates a new state instance with the given initial state.
Arguments
initialState - The initial state of the application. Returns
A State object with the getState and mutate functions.
State A interface that represents the state management module for managing application state.
Properties
getState(selector?: (state: T) => any): any - Retrieves the current state of the application.
selector (optional) - An optional selector function to retrieve a specific value from the state.
mutate(mutator: (currentState: T) => T): T - Mutates the state of the application.
Contributions are welcome! If you would like to contribute to this module, please follow these guidelines:
Fork the repository
Create a new branch for your changes
Make your changes and commit them with descriptive commit messages
Push your changes to your fork
Submit a pull request
This module is released under the MIT License.
FAQs
A Micro State Management
The npm package @brainstack/state receives a total of 158 weekly downloads. As such, @brainstack/state popularity was classified as not popular.
We found that @brainstack/state demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.