Returns all the handles we have cached.
Returns a list of all connected peer ids
Optional
context: anyCreate a new DocHandle by cloning the history of an existing DocHandle.
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.
Optional
initialValue: TThe url or documentId of the handle to delete
Calls each of the listeners registered for a given event.
Return an array listing the events for which the emitter has registered listeners.
Exports a document to a binary format.
The url or documentId of the handle to export
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.
The url or documentId of the handle to retrieve
Imports document binary into the repo.
The binary to import
Optional
args: { docId?: DocumentId }Optional argument specifying what document ID to import into, if at all possible avoid using this, see the remarks below
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.
Return the listeners registered for a given event.
Optional
fn: (...args: ArgumentMap<RepoEvents>[Extract<T, keyof RepoEvents>]) => voidOptional
context: anyOptional
once: booleanAdd a listener for a given event.
Optional
context: anyAdd a one-time listener for a given event.
Optional
context: anyRemove all listeners, or those of the specified event.
Optional
event: keyof RepoEventsRemove the listeners of a given event.
Optional
fn: (...args: ArgumentMap<RepoEvents>[Extract<T, keyof RepoEvents>]) => voidOptional
context: anyOptional
once: boolean
The
Repo
is the main entry point of this libraryRemarks
To construct a
Repo
you will need an StorageAdapter and one or more NetworkAdapters. Once you have aRepo
you can use it to obtain DocHandles.