// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const RuntimeContext = createContext<RuntimeContextState<any, any> | undefined>(undefined);
export function useRuntime<R, ER = never>() {
const context = useContext<RuntimeContextState<R, ER> | undefined>(RuntimeContext);
if (typeof context === "undefined") {
throw Error("useRuntime must be used within an RuntimeContext provider.");
}
return context.runtime;
}
function useSiteDetails() {
const runtime = useRuntime();
return useQuery({
queryKey: ["site", 1444] as const,
queryFn: (args) => {
return Effect.gen(function* ($) {
const service = yield* SiteService;
return yield* service.getById({ id: args.queryKey[1] });
}).pipe(runtime.runPromise);
},
});
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const RuntimeContext = createContext<RuntimeContextState<any, any> | undefined>(undefined);
export function useRuntime<R, ER = never>() {
const context = useContext<RuntimeContextState<R, ER> | undefined>(RuntimeContext);
if (typeof context === "undefined") {
throw Error("useRuntime must be used within an RuntimeContext provider.");
}
return context.runtime;
}
function useSiteDetails() {
const runtime = useRuntime();
return useQuery({
queryKey: ["site", 1444] as const,
queryFn: (args) => {
return Effect.gen(function* ($) {
const service = yield* SiteService;
return yield* service.getById({ id: args.queryKey[1] });
}).pipe(runtime.runPromise);
},
});
}