From 5c9919e4813d39b95306fa131a065d7f8921ca04 Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Sun, 15 Nov 2020 08:37:39 +0000 Subject: [PATCH] Allow `.on` to be chained directly after the constructor so that event handling for the first full snapshot can be added straight after constructor. See #216 (#416) --- src/replay/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index b18c548f..50e926ab 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -194,14 +194,17 @@ export class Replayer { }, 0); } if (firstFullsnapshot) { - this.rebuildFullSnapshot( - firstFullsnapshot as fullSnapshotEvent & { timestamp: number }, - ); + setTimeout(() => { + this.rebuildFullSnapshot( + firstFullsnapshot as fullSnapshotEvent & { timestamp: number }, + ); + }, 1); } } public on(event: string, handler: Handler) { this.emitter.on(event, handler); + return this; } public setConfig(config: Partial) {