import_antigravity
import_antigravity
TTCTheo's Typesafe Cult
Created by Mir on 6/27/2023 in #questions
parse string as duration, are we stuck with momentjs?
you can parse hours and minutes yourself and not be stuck with momentjs
4 replies
TTCTheo's Typesafe Cult
Created by import_antigravity on 6/27/2023 in #questions
tanstack query (requests in bulk vs individual)
I want to do a single bulk request but make tanstack understand that that was actually the same thing as <n> different "individual" requests so future bulk requests would smartly ignore requesting for the same data and individual requests for items that have already been requested in a bulk request are also ignored
10 replies
TTCTheo's Typesafe Cult
Created by import_antigravity on 6/27/2023 in #questions
tanstack query (requests in bulk vs individual)
no because that would still do the individual requests
10 replies
TTCTheo's Typesafe Cult
Created by import_antigravity on 6/27/2023 in #questions
tanstack query (requests in bulk vs individual)
that does get me some of the way there
10 replies
TTCTheo's Typesafe Cult
Created by import_antigravity on 6/27/2023 in #questions
tanstack query (requests in bulk vs individual)
fill the "singular" data that otherwise would be a db call
by this, do you mean queryClient.setQueryData() something like this?
10 replies
TTCTheo's Typesafe Cult
Created by import_antigravity on 11/6/2022 in #questions
trpc response time
I think it may need to watch isFetching rather than isLoading but I need to look into it more
5 replies
TTCTheo's Typesafe Cult
Created by import_antigravity on 11/6/2022 in #questions
trpc response time
import { useEffect, useState } from "react";
import { trpc } from "./trpc";

export function useServerTimeDelta() {
const [start, setStart] = useState(Date.now())
const [end, setEnd] = useState(Date.now())
const [delta, setDelta] = useState(0)
const query = trpc.server.getServerTime.useQuery(undefined, {
onSuccess: (x) => setDelta(x - Date.now()),
staleTime: 1000 * 60 * 5,
});
useEffect(() => {
if (query.isLoading) {
setStart(Date.now())
} else {
setEnd(Date.now())
}
}, [query.isLoading])
const halfTime = (end - start) / 2
return delta + halfTime
}
import { useEffect, useState } from "react";
import { trpc } from "./trpc";

export function useServerTimeDelta() {
const [start, setStart] = useState(Date.now())
const [end, setEnd] = useState(Date.now())
const [delta, setDelta] = useState(0)
const query = trpc.server.getServerTime.useQuery(undefined, {
onSuccess: (x) => setDelta(x - Date.now()),
staleTime: 1000 * 60 * 5,
});
useEffect(() => {
if (query.isLoading) {
setStart(Date.now())
} else {
setEnd(Date.now())
}
}, [query.isLoading])
const halfTime = (end - start) / 2
return delta + halfTime
}
Seems accurate, thanks for the suggestion
5 replies
TTCTheo's Typesafe Cult
Created by import_antigravity on 11/6/2022 in #questions
trpc response time
I think that makes sense
5 replies