Automerge Repo - v2.3.0-alpha.0
    Preparing search index...

    The Repo is the main entry point of this library

    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

    Index

    Constructors

    Properties

    prefixed: string | boolean

    Accessors

    Methods

    • Type Parameters

      Parameters

      Returns this

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

      Type Parameters

      • T

      Parameters

      Returns DocHandle<T>

      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.

    • 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

      • OptionalinitialValue: 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<ArrayBufferLike>>

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

    • Retrieves a document by id. It gets data from the local system, but also emits a document event to advertise interest in the document.

      Type Parameters

      • T

      Parameters

      • id: AnyDocumentId

        The url or documentId of the handle to retrieve

      • options: RepoFindOptions & AbortOptions = {}

      Returns Promise<DocHandle<T>>

    • Imports document binary into the repo.

      Type Parameters

      • T

      Parameters

      • binary: Uint8Array

        The binary to import

      • Optionalargs: { docId?: DocumentId }

        Optional argument specifying what document ID to import into, if at all possible avoid using this, see the remarks below

      Returns DocHandle<T>

      If no document ID is provided, a new document will be created. When specifying the document ID it is important to ensure that two documents using the same ID share the same history - i.e. don't create a document with the same ID on unrelated processes that have never communicated with each other. If you need to ship around a bunch of documents with their IDs consider using the automerge-repo-bundles package which provides a serialization format for documents and IDs and handles the boilerplate of importing and exporting these bundles.

    • 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: ArgumentMap<RepoEvents>[Extract<T, keyof RepoEvents>]) => void)[]

    • Type Parameters

      Parameters

      • event: T
      • Optionalfn: (...args: ArgumentMap<RepoEvents>[Extract<T, keyof RepoEvents>]) => void
      • Optionalcontext: any
      • Optionalonce: boolean

      Returns this

    • Add a listener for a given event.

      Type Parameters

      Parameters

      Returns this

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

      Type Parameters

      Parameters

      Returns this

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

      Parameters

      • Optionalevent: keyof RepoEvents

      Returns this

    • Remove the listeners of a given event.

      Type Parameters

      Parameters

      • event: T
      • Optionalfn: (...args: ArgumentMap<RepoEvents>[Extract<T, keyof RepoEvents>]) => void
      • Optionalcontext: any
      • Optionalonce: boolean

      Returns this