NinjaBunny
NinjaBunny
Explore posts from servers
TTCTheo's Typesafe Cult
Created by NinjaBunny on 10/26/2023 in #questions
WebSocket on Server Component
I appreciate it
21 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 10/26/2023 in #questions
WebSocket on Server Component
Thank you for the help 🙂
21 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 10/26/2023 in #questions
WebSocket on Server Component
nope the websocket server is from a different microservice, I just thought it would be cool if we can revalidate the path like that, but it makes sense
21 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 10/26/2023 in #questions
WebSocket on Server Component
or something marked as "use client"
21 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 10/26/2023 in #questions
WebSocket on Server Component
even if it's on a client component?
21 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 10/26/2023 in #questions
WebSocket on Server Component
yea I know, but I'm forced into using websockets because I need a constant data feed for certain parts of my teams application. dealing with realtime events and stuff
21 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 10/26/2023 in #questions
WebSocket on Server Component
I had a feeling I would have to use a client component, but it would be cool to do something like this on the server
21 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 10/26/2023 in #questions
WebSocket on Server Component
ahhh okay thanks
21 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
never mind I fixed it I needed to give useNavigation a type
12 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
it didn't do this when I passed props down, but now it says it's of type never
12 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
12 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
I guess I just assumed they would've used the hook if there was one, not just rabbithole props through components
12 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
oh okay I see thank you, for helping me understand
12 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
this is from the react native docs
12 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 4/2/2023 in #questions
SPA or MPA for react native dev
This is the example I was looking at, in which they were passing down the navigation prop
const HomeScreen = ({navigation}) => {
return (
<Button
title="Go to Jane's profile"
onPress={() =>
navigation.navigate('Profile', {name: 'Jane'})
}
/>
);
};
const ProfileScreen = ({navigation, route}) => {
return <Text>This is {route.params.name}'s profile</Text>;
};
const HomeScreen = ({navigation}) => {
return (
<Button
title="Go to Jane's profile"
onPress={() =>
navigation.navigate('Profile', {name: 'Jane'})
}
/>
);
};
const ProfileScreen = ({navigation, route}) => {
return <Text>This is {route.params.name}'s profile</Text>;
};
12 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 3/23/2023 in #questions
When should I not use tRPC
in other words just use tRPC lol
50 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 2/16/2023 in #questions
What is the best way to type an API Response
or something along these lines?
5 replies
TTCTheo's Typesafe Cult
Created by NinjaBunny on 2/16/2023 in #questions
What is the best way to type an API Response
so I understand unions as a function param, but in the case where if I wanted to do something like
type Response<T> = { status: 'ok'; statusCode: number; data: T } | { status: 'error': statusCode: number; error: Error };

const response = await fetch<Response>('http://localhost:3000/api/auth/login', {
method: "GET",
headers: {
"Content-Type": "application/json",
},
body: {
email: email.toLowerCase(),
password,
},
});

if(response.status === 'ok') {
//do something
return;
}

//do error
type Response<T> = { status: 'ok'; statusCode: number; data: T } | { status: 'error': statusCode: number; error: Error };

const response = await fetch<Response>('http://localhost:3000/api/auth/login', {
method: "GET",
headers: {
"Content-Type": "application/json",
},
body: {
email: email.toLowerCase(),
password,
},
});

if(response.status === 'ok') {
//do something
return;
}

//do error
I guess this would be the logic on this then right?
5 replies