feat: add @effect/rpc
This commit is contained in:
30
apps/expo/app/rpc.tsx
Normal file
30
apps/expo/app/rpc.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user