- guide.selectedUUID is used to determina current uuid - all the game related midifications are stored independantly per UUID - no global indicators
21 lines
494 B
JavaScript
21 lines
494 B
JavaScript
import { usePolling } from "../hook/api";
|
|
import { useUserStateReducer } from "../reducer/user";
|
|
|
|
export default function useUserApi() {
|
|
const [state, dispatchState] = useUserStateReducer();
|
|
|
|
const useGetUser = () => {
|
|
const onSuccess = (userJson) => {
|
|
dispatchState({ type: "parse", userJson });
|
|
}
|
|
|
|
usePolling('/api/user', { onSuccess }); // <<-- fetch once
|
|
}
|
|
|
|
return {
|
|
state,
|
|
api : {
|
|
useGetUser
|
|
}
|
|
}
|
|
} |