Skip to content

File tree

types/sharedb/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ declare namespace sharedb {
221221
private _removeStream(channel, stream): void;
222222
}
223223

224-
abstract class MilestoneDB {
224+
interface MilestoneDBEventMap {
225+
"error": (error: Error) => void;
226+
"save": (collection: string, snapshot: Snapshot) => void;
227+
}
228+
229+
abstract class MilestoneDB extends ShareDB.TypedEmitter<MilestoneDBEventMap> {
225230
close(callback?: BasicCallback): void;
226231
getMilestoneSnapshot(collection: string, id: string, version: number, callback?: BasicCallback): void;
227232
saveMilestoneSnapshot(collection: string, snapshot: Snapshot, callback?: BasicCallback): void;

types/sharedb/sharedb-tests.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ backend.on("someCustomEvent", (arg0: string, arg1: number) => {});
8080
backend.db.getOps("someCollection", "someId", null, null, {}, () => {});
8181
backend.db.getSnapshotBulk("someCollection", ["id1", "id2"], null, null, () => {});
8282

83+
backend.milestoneDb.once("save", (collection, snapshot) => {
84+
console.log(collection, snapshot.data);
85+
});
86+
backend.milestoneDb.on("error", (error) => console.error(error.message));
87+
8388
console.log(backend.pubsub);
8489
console.log(backend.extraDbs);
8590

0 commit comments

Comments
 (0)