0.1.0 • Published 6 years ago

phoenix-types v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

phoenix-types

Types for the Phoenix Framework JS Library version 1.3.0.

Installation

npm install -S phoenix-types

Usage

import { Socket, Channel } from "phoenix";

interface SocketAuth {
  auth_token: string
}

interface ChannelTx {
  message: string
}

interface ChannelRx {
  message: string,
  user: string
}

const params = {auth_token: "..."};
let socket = new Socket<SocketAuth>("/my_endpoint", {params});
socket.connect();
let channel = socket.channel<ChannelTx, ChannelRx>("room:lobby");
channel.join()
  .receive("ok", () => console.log("connected"))
  .receive("error", () => console.error("could not connect"));