
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
@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 13 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.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.