Real Time Question

How do i basically set a timeout for this so i dont have this run every second pinging to the server. Thanks in advance

useEffect(() => {
    async function loadProfile() {
      const { id, created_at, user_id, username, karma, avatar } =
        await getProfile();
      setProfile({ id, created_at, user_id, username, karma, avatar });
      await client
        .from('*')
        .on('*', async (payload) => {
          const { id, created_at, user_id, username, karma, avatar } = await getProfile();
          setProfile({id, created_at, user_id, username, karma, avatar});
        })
        .subscribe();
    }
    loadProfile();
  }, [profile]);
Was this page helpful?