@arpabet/vrpc-vue
v0.2.1
Published
Vue 3 plugin and composables for value-rpc: useVrpcCall, useVrpcStream, useVrpcConnection
Downloads
221
Maintainers
Readme
@arpabet/vrpc-vue
Vue 3 plugin + composables for value-rpc.
// main.ts
import { createVrpc } from "@arpabet/vrpc-vue";
app.use(createVrpc({ url: import.meta.env.VITE_VRPC_URL }));<script setup lang="ts">
const { data, pending, error, refresh } = useVrpcCall<User>("user.get", () => [id.value]);
const { latest, values, state, cancel } = useVrpcStream<Event>("events.tail", ["orders"]);
const { status, connected } = useVrpcConnection();
const client = useVrpc(); // full @arpabet/vrpc client (chat, putStream, reverse calls)
</script>useVrpcCallre-runs when reactive args change and aborts superseded runs.useVrpcStreamgrants flow-control credit as values are consumed and cancels the stream on unmount.keepLastbounds the retained window.- SSR-safe: on the server the composables render their pending state and never open a socket.
- For caching/dedup/SWR, feed
client.callinto@tanstack/vue-query'squeryFn— this package deliberately ships no cache.
