Created
May 25, 2024 13:47
-
-
Save astrarudra/161316f64b59c112e9f1c56d4c97dbbe to your computer and use it in GitHub Desktop.
Zustand Controller - Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useOxyStore } from "../OxyStore"; | |
const { setState, setLoader } = useOxyStore.getState() | |
// ^ here, get all the functions ur need. | |
const generalController = { // Move this to a file | |
demo: async () => { | |
setLoader("Loading Gist Data") | |
const response = await fetch('https://gis....') | |
const json = await response.json() | |
setState({ demoData: json.data, fsLoader: null}) | |
} // Clear Flow! No sideEffect Saga! | |
} | |
export const OxyController = { // modular controllers. | |
...generalController, | |
...otherControllers, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment