Files
browser-wakatime/src/utils/checkCurrentUser.ts
2023-01-11 09:03:05 -05:00

18 lines
504 B
TypeScript

import { RootStore } from '../stores/createStore';
import { fetchCurrentUser } from '../reducers/currentUser';
type unsub = () => void;
export default (store: RootStore) =>
(time: number): unsub => {
const fetchUser = () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
store.dispatch(fetchCurrentUser());
};
fetchUser();
const timeout = setInterval(fetchUser, time);
return () => {
clearInterval(timeout);
};
};