Skip to content

Instantly share code, notes, and snippets.

@happylinks
Created December 13, 2020 13:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save happylinks/afd8ad5c82489764f6ad3ce0316908e8 to your computer and use it in GitHub Desktop.
Save happylinks/afd8ad5c82489764f6ad3ce0316908e8 to your computer and use it in GitHub Desktop.
RoomService V2 ReasonML bindings
type key = string;
type rs;
type options = {auth: string};
[@bs.module "@roomservice/browser"] [@bs.new]
external make: options => rs = "RoomService";
type room;
[@bs.send] external room: (rs, string) => Js.Promise.t(room) = "room";
module Presence = {
type t;
[@bs.send] external make: room => t = "presence";
[@bs.send]
external subscribe: (t, key, Js.Json.t => unit) => t = "subscribe";
[@bs.send] external unsubscribe: (t, key) => unit = "unsubscribe";
[@bs.send] external set: (t, key, Js.Json.t) => unit = "set";
};
module Map = {
type t;
[@bs.send] external make: (room, key) => t = "map";
[@bs.send] external set: (t, key, Js.Json.t) => unit = "set";
[@bs.send] external get: (t, key) => Js.Json.t = "get";
[@bs.send] external delete: (t, key) => Js.Json.t = "delete";
[@bs.send] external toObject: t => Js.Json.t = "toObject";
[@bs.send]
external subscribe: (room, key, Js.Json.t => unit) => unit = "subscribe";
[@bs.send] external unsubscribe: (room, key) => unit = "unsubscribe";
};
module List = {
type t;
[@bs.send] external make: (room, key) => t = "list";
[@bs.send] external set: (t, key, Js.Json.t) => unit = "set";
[@bs.send] external push: (t, Js.Json.t) => unit = "push";
[@bs.send]
external subscribe: (room, key, Js.Json.t => unit) => unit = "subscribe";
[@bs.send] external unsubscribe: (room, key) => unit = "unsubscribe";
[@bs.send] external toArray: t => array(Js.Json.t) = "toArray";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment