0.14.1 • Published 1 year ago
@musubi/in-memory-link v0.14.1
@musubi/in-memory-link
Adapter for using Musubi with in-memory communication.
Documentation
Full documentation for musubi
can be found here.
Installation
# npm
npm install @musubi/in-memory-link
# Yarn
yarn add @musubi/in-memory-link
Usage
import { defineSchema, CommunicatorClient, MusubiReceiver } from "@musubi/core";
import { createInMemoryLink } from "@musubi/in-memory-link";
import { z } from "zod";
const schema = defineSchema({
queries: {
greet: query()
.withPayload(
z.object({
name: z.string()
})
)
.withResult(z.string())
}
});
const memoryLink = createInMemoryLink();
const receiver = new MusubiReceiver(schema, [memoryLink.receiver]);
receiver.handleQuery('greet', payload => `Hello ${payload.name}`);
async function main() {
const client = new CommunicatorClient(schema, [memoryLink.client]);
// Querying the greeting
const response = await client.query("greet", {
name: "John"
});
console.log("response", response); // Hello John
}
0.14.1
1 year ago
0.13.0
1 year ago
0.14.0
1 year ago
0.12.1
2 years ago
0.12.2
2 years ago
0.12.3
2 years ago
0.12.4
2 years ago
0.12.5
2 years ago
0.11.0
2 years ago
0.12.0
2 years ago
0.11.1
2 years ago
0.11.2
2 years ago
0.11.3
2 years ago
0.10.0
2 years ago
0.9.1
2 years ago
0.9.0
2 years ago
0.8.0
2 years ago
0.7.1
2 years ago
0.7.0
2 years ago
0.6.0
2 years ago
0.5.0
2 years ago
0.4.1
2 years ago
0.4.0
2 years ago
0.3.1
2 years ago
0.3.0
2 years ago
0.2.0
2 years ago
0.1.0
2 years ago