
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
store2state
Advanced tools
This library provides a robust and flexible state management solution for JavaScript and TypeScript applications, with a focus on React integration. It includes a powerful Store class, custom hooks for React, and an AsyncAction utility for handling asynch
This library provides a robust and flexible state management solution for JavaScript and TypeScript applications, with a focus on React integration. It includes a powerful Store class, custom hooks for React, and an AsyncAction utility for handling asynchronous operations.
useStore
and useStoreSelector
)npm install store2state
import { createStore } from 'store2state';
const initialState = { count: 0 };
const store = createStore(initialState);
import { useStore } from 'storee2state';
function Counter() {
const { get, set } = useStore(store);
return (
<div>
<p>Count: {get().count}</p>
<button onClick={() => set(state => ({ count: state.count + 1 }))}>
Increment
</button>
</div>
);
}
import { useStoreSelector } from 'store2state';
function CountDisplay() {
const count = useStoreSelector(store, state => state.count);
return <p>Count: {count}</p>;
}
import { createAsyncAction, Status } from 'store2state';
const fetchUserAction = createAsyncAction(store, async (store, setStatus, userId) => {
setStatus(Status.LOADING);
try {
const response = await fetch(`/api/users/${userId}`);
const user = await response.json();
setStatus(Status.SUCCESS, user);
return user;
} catch (error) {
setStatus(Status.ERROR, error);
throw error;
}
});
// Using the async action
fetchUserAction.call(123)
.then(user => console.log(user))
.catch(error => console.error(error));
// Checking the status
console.log(fetchUserAction.isLoading);
Store<State>
The main class for state management.
get()
: Get the current stateset(newValue: SetterFunc<State>)
: Update the statesubscribe(eventName: string, subscriber: Subscriber<State>)
: Subscribe to state changesunsubscribe(eventName: string, id: string)
: Unsubscribe from state changesdispatch(eventName: string)
: Dispatch an event to subscribersuseStore<State>(store: Store<State>)
: Hook for using the store in React componentsuseStoreSelector<State, Selected>(store: Store<State>, selector: (state: State) => Selected)
: Hook for selecting specific parts of the stateUtility for handling asynchronous operations with status tracking.
call(...args: Args)
: Execute the async actioncancel()
: Cancel the ongoing async actiononError(effect: AsyncActionEffect<State, ErrorPayload>)
: Add an error effectonSuccess(effect: AsyncActionEffect<State, SuccessPayload>)
: Add a success effectonLoading(effect: AsyncActionEffect<State, void>)
: Add a loading effectstore2state
is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
This library provides a robust and flexible state management solution for JavaScript and TypeScript applications, with a focus on React integration. It includes a powerful Store class, custom hooks for React, and an AsyncAction utility for handling asynch
We found that store2state demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.