Skip to content

0.0.2

Latest
Compare
Choose a tag to compare
@SampaioLeal SampaioLeal released this 21 Jan 01:18
· 2 commits to main since this release

Generic Client/Server

Now you can define contracts for your clients with Generics!

// service2/contract.ts
import { RPCReply } from "../../mod.ts";

type ServiceContracts = {
  hello: (clientName: string) => Promise<RPCReply<void>>;
};

export default ServiceContracts;

// service1/mod.ts

import Service2Contracts from "../service2/contract.ts"

const service2 = await initializeClient<Service2Contracts>({
  host: "ws://localhost:3002",
});

// and now you can type:
service2.
// and your editor will autocomplete the services defined in the contract like the hello() service