The Repo is the main entry point of this library

Remarks

To construct a Repo you will need an StorageAdapter and one or more NetworkAdapters. Once you have a Repo you can use it to obtain DocHandles.

Hierarchy

Constructors

Properties

prefixed: string | boolean

Accessors

Methods

  • Type Parameters

    Parameters

    • event: T
    • fn: ((...args) => void)
    • Optional context: any

    Returns this

  • Create a new DocHandle by cloning the history of an existing DocHandle.

    Type Parameters

    • T

    Parameters

    Returns DocHandle<T>

    Remarks

    This is a wrapper around the clone function in the Automerge library. The new DocHandle will have a new URL but will share history with the original, which means that changes made to the cloned handle can be sensibly merged back into the original.

    Any peers this Repo is connected to for whom sharePolicy returns true will be notified of the newly created DocHandle.

    Throws

    if the cloned handle is not yet ready or if clonedHandle.docSync() returns undefined (i.e. the handle is unavailable).

  • Creates a new document and returns a handle to it. The initial value of the document is an empty object {} unless an initial value is provided. Its documentId is generated by the system. we emit a document event to advertise interest in the document.

    Type Parameters

    • T

    Parameters

    • Optional initialValue: T

    Returns DocHandle<T>

  • Calls each of the listeners registered for a given event.

    Type Parameters

    Parameters

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (keyof RepoEvents)[]

  • Exports a document to a binary format.

    Parameters

    Returns Promise<undefined | Uint8Array>

    Promise<Uint8Array | undefined> - A Promise containing the binary document, or undefined if the document is unavailable.

  • Return the number of listeners listening to a given event.

    Parameters

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    Parameters

    • event: T

    Returns ((...args) => void)[]

  • Returns {
        documents: {
            [key: string]: any;
        };
    }

    • documents: {
          [key: string]: any;
      }
      • [key: string]: any
  • Type Parameters

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
    • Optional context: any
    • Optional once: boolean

    Returns this

  • Add a listener for a given event.

    Type Parameters

    Parameters

    • event: T
    • fn: ((...args) => void)
    • Optional context: any

    Returns this

  • Add a one-time listener for a given event.

    Type Parameters

    Parameters

    • event: T
    • fn: ((...args) => void)
    • Optional context: any

    Returns this

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: keyof RepoEvents

    Returns this

  • Remove the listeners of a given event.

    Type Parameters

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
    • Optional context: any
    • Optional once: boolean

    Returns this