
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@ecosy/store
Advanced tools
Lightweight state management with slices, reducers, and event-driven architecture
Lightweight state management with slices, reducers, and event-driven architecture for TypeScript applications.
npm install @ecosy/store
# or
yarn add @ecosy/store
Note:
@ecosy/coreis installed automatically as a dependency.
createSliceCreates a state slice with auto-generated action creators, a reducer, and event channels.
import { createSlice, type PayloadAction } from "@ecosy/store";
const counterSlice = createSlice({
name: "counter",
initialState: { count: 0 },
reducers: {
increment: (state) => ({ ...state, count: state.count + 1 }),
decrement: (state) => ({ ...state, count: state.count - 1 }),
add: (state, action: PayloadAction<number>) => ({
...state,
count: state.count + action.payload,
}),
},
});
// Auto-generated action creators
counterSlice.actions.increment();
// => { type: "$counter:increment" }
counterSlice.actions.add(5);
// => { type: "$counter:add", payload: 5 }
// Reducer
const next = counterSlice.reducer({ count: 0 }, counterSlice.actions.add(5));
// => { count: 5 }
// Event channels
counterSlice.events;
// => { counter: { increment: "$counter:increment", decrement: "$counter:decrement", add: "$counter:add" } }
createStoreCreates a store backed by a Subscriber instance with event wiring and typed actions.
import { createStore } from "@ecosy/store";
const { store, actions } = createStore({
name: "app",
initialState: { theme: "light" },
reducers: {
toggleTheme: (state) => ({
...state,
theme: state.theme === "light" ? "dark" : "light",
}),
},
});
// Listen to state changes
store.onStateChange((state) => {
console.log("Theme:", state.theme);
});
// Dispatch actions
actions.toggleTheme(); // logs "Theme: dark"
// Get current state
store.getState(); // { theme: "dark" }
Fire-and-forget events that don't modify state:
const { store, actions } = createStore({
initialState: { count: 0 },
reducers: {
increment: (state) => ({ ...state, count: state.count + 1 }),
},
signals: ["reset", "sync"],
});
// Signals are available as actions
actions.signals.reset();
actions.signals.sync();
| Type | Description |
|---|---|
PayloadAction<P, T, M, D> | Action with optional payload, meta, and delta |
AnyAction | PayloadAction<any, any, any, any> |
Reducers<State, Action> | Map of reducer handlers |
Slice<State, R, N> | Return type of createSlice |
CreateStoreOptions | Options for createStore |
CreateStoreReturn | Return type of createStore |
getType(prefix, key)Generates event channel strings:
import { getType } from "@ecosy/store";
getType("counter", "increment"); // "$counter:increment"
| Package | Description |
|---|---|
@ecosy/core | Types, utilities, and pub/sub subscriber |
@ecosy/react | React hooks for @ecosy/store |
MIT
FAQs
Lightweight state management with slices, reducers, and event-driven architecture
We found that @ecosy/store demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

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.