feat: add @effect/rpc

This commit is contained in:
Max Koon
2025-11-28 15:04:42 -05:00
parent 02dd064d99
commit 3ebb7ee796
9 changed files with 154 additions and 32 deletions

30
apps/expo/app/rpc.tsx Normal file
View File

@@ -0,0 +1,30 @@
import { Button, Text, View } from "react-native";
import { AtomRpc, useAtomSet } from "@effect-atom/atom-react";
import { Layer } from "effect";
import { LinkRpcs } from "@money/shared/rpc";
import { FetchHttpClient } from "@effect/platform";
import { RpcClient, RpcSerialization } from "@effect/rpc";
class Client extends AtomRpc.Tag<Client>()("RpcClient", {
group: LinkRpcs,
protocol: RpcClient.layerProtocolHttp({
url: "http://laptop:3000/rpc",
}).pipe(Layer.provide([RpcSerialization.layerJson, FetchHttpClient.layer])),
}) {}
export default function Page() {
const create = useAtomSet(Client.mutation("CreateLink"));
const onPress = () => {
create({
payload: void 0,
});
};
return (
<View>
<Text>RPC Test</Text>
<Button onPress={onPress} title="Create link" />
</View>
);
}

View File

@@ -15,6 +15,7 @@
},
"dependencies": {
"@better-auth/expo": "^1.3.27",
"@effect-atom/atom-react": "^0.4.0",
"@expo/vector-icons": "^15.0.2",
"@money/shared": "workspace:*",
"@money/ui": "workspace:*",