1.0.1 • Published 9 months ago

@kasif-apps/conductor v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Conductor

Install

For client in browsers

npm install @kasif-apps/conductor
yarn add @kasif-apps/conductor
pnpm install @kasif-apps/conductor

For server in Deno

import { Conductor } from "https://raw.githubusercontent.com/kasif-apps/conductor/main/src/mod.ts";

Usage

Create a new Conductor instance and pass the options

const conductor = new Conductor(serverConfig, exposables);

Server Config

type ServerConfig = {
  host: string; // host server to connect to. You can pass an empty string while consuming through Deno
  port: number; // server port
};

Exposables

Exposables are any type of constant that is JSON serializable or a function.

Example

// main.server.ts
import { Conductor } from "https://raw.githubusercontent.com/kasif-apps/conductor/main/src/mod.ts";

const serverConfig = {
  host: "localhost",
  port: 8000,
};

new Conductor(serverConfig, {
  foo: "bar",
  greet(name: string): string {
    return `Hello ${name}!`;
  },
});

// main.client.ts
import { Conductor } from "@kasif-apps/conductor";

const serverConfig = {
  host: "localhost",
  port: 8000,
};

// not exposing anything from the client
const conductor = new Conductor(serverConfig, {});

conductor.addEventListener("ready", async () => {
  const foo = await conductor.get<string>("foo"); // bar
  const greeting = await conductor.call<string>("greet", ["Muhammed Ali"]); // Hello Muhammed Ali!
});
1.0.1

9 months ago

1.0.0

9 months ago

0.2.0

9 months ago

0.1.0

9 months ago

0.0.1

9 months ago

0.0.0

9 months ago