-
-
Save morintd/eb469922e5400a967223e37013f3c29f to your computer and use it in GitHub Desktop.
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 { useQuery } from "@tanstack/react-query"; | |
import { useDependencyContext } from "../common/dependency-context"; | |
import { useMemo } from "react"; | |
import { GameDomainModel } from "./game.domain-model"; | |
import { Initialize } from "./use-cases/initialize.use-case"; | |
export function useInitializeQuery() { | |
const dependencies = useDependencyContext(); | |
const initialize = useMemo(() => { | |
return new Initialize(dependencies.board); | |
}, [dependencies.board]); | |
const query = useQuery<GameDomainModel.GameState>({ | |
queryKey: ["initialize"], | |
queryFn: () => initialize.execute(), | |
}); | |
return { | |
data: query.data, | |
error: query.error, | |
isPending: query.isPending, | |
isError: query.isError, | |
isSuccess: query.isSuccess, | |
}; | |
} | |
export function useHomeController() { | |
const initialize = useInitializeQuery(); | |
return { | |
initialize, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment