Constructs an IndexedDBDocStore.
You typically only need one IndexedDBDocStore per app, since it can subscribe multiple documents.
The name of the database to use. Default: "@collabs/indexeddb".
The name of this class's IndexedDB database, set in the constructor.
Default: "@collabs/indexeddb".
Deletes all documents in our database.
Closes our IndexedDB database connection and unsubscribes all documents.
Future method calls will throw an error.
Deletes docID
from localStorage.
Returns all docID
s with state stored in our database.
Emits an event, which triggers all the registered event handlers.
Event handlers are called in the order they are added. Errors in
event handlers are captured and logged (with console.error
),
not propagated to the caller.
Name of the event to emit.
Event object to pass to the event handlers.
Registers an event handler that is triggered when the event happens.
Name of the event to listen on.
Callback that handles the event.
If true, the event handler is triggered at most once (the next time the event happens), then unsubscribed.
An "off" function that removes the event handler when called.
Registers an event handler that is triggered when the event happens.
An "off" function that removes the event handler when called.
Subscribes doc
to updates stored under docID
.
All existing updates under docID
will be loaded into doc
asynchronously, emitting a "Load" event when finished (including
if there are no existing updates).
Also, all new updates to doc
will be saved under docID
,
emitting a "Save" event whenever the IndexedDB state becomes up-to-date with doc
.
This includes both local operations and updates from other sources.
The document to subscribe.
An arbitrary string that identifies which stored state to use.
Unsubscribes doc
from its subscribed docID
(if any).
Further updates to doc
will not be saved.
Generated using TypeDoc
Stores updates to Collabs documents in IndexeddDB.
To load existing state into a document (if any) and store future updates to that document, call subscribe. You will need to supply a
docID
that identifies which stored state to use.This class is designed to work seamlessly with other sources of updates, such as @collabs/ws-client. In particular, updates from those sources will be stored alongside local operations.
See also: @collabs/local-storage, which stores updates in localStorage instead of IndexedDB.