Skip to content

Instantly share code, notes, and snippets.

@astrarudra
Created May 25, 2024 13:47
Show Gist options
  • Save astrarudra/161316f64b59c112e9f1c56d4c97dbbe to your computer and use it in GitHub Desktop.
Save astrarudra/161316f64b59c112e9f1c56d4c97dbbe to your computer and use it in GitHub Desktop.
Zustand Controller - Controller
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