You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/frontend/src/contexts/Online.ts

29 lines
631 B

import { createContext, useContext } from "react";
const OnlineContext = createContext<{
online: boolean;
setOnline: (online: boolean) => void;
} | null>(null);
export function useIsOnline() {
const context = useContext(OnlineContext);
if (context === null) {
throw new Error("useIsOnline must be used within a OnlineProvider");
}
return context.online;
}
export function useSetOnline() {
const context = useContext(OnlineContext);
if (context === null) {
throw new Error("useSetOnline must be used within a OnlineProvider");
}
return context.setOnline;
}
export default OnlineContext.Provider;