cyremur
TTCTheo's Typesafe Cult
•Created by cyremur on 11/2/2023 in #questions
How to keep track of multiple running mutations with same function but different input variables?
I have a single mutate function that's basically:
const doWork = api.example.doWork.useMutation()
And I call it from a bunch of buttons with
doWork.mutate{taskId: <someNumber>}
This works in executing tasks in parallel, but I can no longer use doWork.isLoading to prevent users from submitting the same tasks multiple times before they resolve.
My best bet was trying to put a list of active task ids in state and then clearing ids from the list in doWork.onSuccess, but now I have issues with inconsistent state / race conditions.
Am I on the right path and just need to update my setState or is there a better way of doing this?
2 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 7/5/2023 in #questions
Memoize function in typescript
I want to memoize a pure function in ts that's just a static export without class. Typescript-memoize seems to need a class for the decorator to work. Do I have to wrap my functions into a class and possibly use a singleton or is there a simpler way to pull off memoization?
26 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 6/27/2023 in #questions
Discord server setup
Is there like a template or setup script to setup a nice discord server or should I just look around the ones I like and try to replicate a good channel structure manually?
2 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 6/5/2023 in #questions
Vercel Storage as CDN
I was looking into using the new vercel Storage stuff as an alternative to s3 for serving 100-200 static images for a Web app. I thought blob might be right but egress seems super tight? Any experiences or suggestions? Or should I just serve images elsewhere?
13 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 3/15/2023 in #questions
Deceptive Site Warning
6 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 1/23/2023 in #questions
Powering camera while streaming?
To my resident streamers: How do you power your camera during a stream? I have a Canon (EOS M50 I think) and just wanna put it on a stand and forget about it.
5 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 1/19/2023 in #questions
Can I zod this gamestate?
It's a game. There is more nested interfaces (Field, Entity, Card, Deck). Should I just give up and use z.any() or is this still reasonable with zod? 😄
6 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 1/11/2023 in #questions
ct3a + react-hexgrid npm package = "Cannot use import statement outside a module"
So I'm a bit confused about this and it's somewhat hard to google cause content mills spam the search with unrelated(?) beginner tutorials...
Basically, when I try to import from the [email protected] npm package from a ct3a app, I get the error on page load.
Any hints for understanding this problem are appreciated.
FWIW, I tried the package with a create-react-app and at least it spat out a webpage (with a couple warnings/errors).
Here's a github minimal example to run: https://github.com/cyremur/t3-hexgrid-minmal-error
Steps to reproduce:
1. create-t3-app
2. npm i react-hexgrid
3. put
import { Hexagon } from 'react-hexgrid';
and const hexes = GridGenerator.hexagon(6);
in index.tsx
Error message:
2 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 12/4/2022 in #questions
Accidental state persistence across next dynamic routes?
Just noticed that /profile/[username].tsx persists
useState()
between different users in my app... My solution and the first stackoverflow answer I found is:
This works for me but it feels weird after avoiding useEffects before. Is there a better way to do this or is the useEffect as good as it gets?1 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 12/2/2022 in #questions
TRPC QueryClient access in ct3a?
I want to disable windows focus refetching globally like here: https://tanstack.com/query/v4/docs/guides/window-focus-refetching
How do I access the queryclient in the scaffolded trpc in ct3a?
4 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 11/29/2022 in #questions
How difficult is it to port a t3 app to t3-turbo React Native?
Building a new app that might end up on mobile and trying to gauge if it makes sense to learn t3-turbo React Native now and start there or just build it quick with t3 and then worry about mobile apps later.
1 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 11/25/2022 in #questions
Is SQLite really faster reads than MySQL (in low concurrency apps)?
Tested with local DBs and same prisma frontend MySQL had 5-6 times the loading times for big sort queries (top 100 of a huge scoreboard).
3 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 10/17/2022 in #questions
Synchronizing TS Objects with functions attached?
I have TS Objects with functions (as part of a browser game).
Is there a simple way or library to take an object, strip it of its functions, send over the data, and rebuild it into a full object with functions attached.
My current best idea is to use a sort of (de-)serialization middleware between Redux/Zustand and liveblocks.
Any hints/tricks/best practices/libraries are welcome.
16 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 10/17/2022 in #questions
What was the cloud DB with SQL via HTML hype recently?
I know something was mentioned on one of Theo's streams but I can't remember.
10 replies
TTCTheo's Typesafe Cult
•Created by cyremur on 10/9/2022 in #questions
What's the best way to attach functions to a TypeScript interface?
So I currently I have game objects with properties attached. For example, a creature card with properties attached. Now I have code like this:
I kinda hate this, especially if I have to write code like this all over the place.
Now ideally, I want to just put a predicate to the card so I implement it once and can just call
Is this possible with interfaces at all? Like an abstract prototype-ish implementation?
Some caveats:
- I cannot use classes, cause that messes up my Redux state management and jsonifying states in general.
- I also considered utility classes like
cardFunctions
then I guess you could do
not the biggest fan but if that's the best there is I might go for it23 replies