How to use the sharedb/lib/client.types.map function in sharedb

To help you get started, we’ve selected a few sharedb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lostintangent / kyte / packages / kyte / lib / share-client.js View on Github external
module.exports = async (webSocket, content = "") => {
  // ShareDB operates against JSON documents, so we need to
  // ensure that we can perform OT operations on child text properties,
  // since that is the core focus on the Kyte CLI.
  types.map["json0"].registerSubtype(textType);

  // "Wrap" the provided WebSocket with the ShareDB app protocol client
  const shareConnection = new Connection(webSocket);

  // Create the remote document, using the initial contents if specified
  const document = shareConnection.get("documents", "demo.js");
  if (content) {
    await promisify(document.create).call(document, { content });
  }

  return document;
};