Open UpperCod opened 2 years ago
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.
Describe the solution you'd like
What if we use hooks inside a state manager? 🤔... Imagine reusing custom Hooks even in the Store, example:
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.