@passionware/simple-store v0.0.0-dev-20240511210804
Simple store
Simple Store is a lightweight state hook that which functions similarly to the React's useState() hook but enables data sharing between instances created using the same factory.
Simple Store is particularly useful for test and Storybook code. It allows you to expose mock hook implementations within a factory, enabling data sharing without the need for specialized contexts.
Usage
const createMockItemsDomain = (initialData) => {
const itemsStore = createSimpleStore(initialData);
return {
useAddItem: () => {
const [value, setValue] = itemsStore.useValue();
return (item) => {
itemsStore.setValue([...value, item]);
};
},
useItems: () => {
const [value, setValue] = itemsStore.useValue();
return value;
},
};
};
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
11 months ago
1 year ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
12 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago