-
-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the solution you'd like
What if we use hooks inside a state manager? 🤔... Imagine reusing custom Hooks even in the Store, example:
import { createStore } from "@atomico/hooks/store";
import { usePromise } from "@atomico/hooks/use-promise";
const store = createStore(
{
products: {},
},
{
getProducts(store) {
const [result, status] = usePromise(() => myApi(`/products`));
return {
products: {
result,
status,
},
};
},
}
);
store.actions.getProducts();
const { result, status } = store.state.products;Additional context
The goal of this API is to reuse customHooks to compose states at the Store level.
✍️ All positive or negative opinions about this proposal are welcome.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request