Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie632 committed Oct 18, 2024
1 parent 7ca8632 commit 4dded10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class Replayer {
private mouseTail: HTMLCanvasElement | null = null;
private tailPositions: Array<{ x: number; y: number }> = [];

private emitter: Emitter = mitt();
private emitter: Emitter = mitt() as Emitter;

private nextUserInteractionEvent: eventWithTime | null;

Expand Down Expand Up @@ -331,6 +331,8 @@ export class Replayer {
this.applySelection(this.lastSelectionData);
this.lastSelectionData = null;
}

this.emitter.emit(ReplayerEvents.FlushEnd);
});
this.emitter.on(ReplayerEvents.PlayBack, () => {
this.firstFullSnapshot = null;
Expand Down Expand Up @@ -577,6 +579,7 @@ export class Replayer {
this.mediaManager.reset();
this.config.root.removeChild(this.wrapper);
this.emitter.emit(ReplayerEvents.Destroy);
this.emitter.all.clear();
}

public startLive(baselineTime?: number) {
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ export type Emitter = {
on(type: string, handler: Handler): void;
emit(type: string, event?: unknown): void;
off(type: string, handler: Handler): void;
all: Map<string | symbol, Handler[]>;
};

export type Arguments<T> = T extends (...payload: infer U) => unknown
Expand All @@ -675,6 +676,7 @@ export enum ReplayerEvents {
EventCast = 'event-cast',
CustomEvent = 'custom-event',
Flush = 'flush',
FlushEnd = 'flush-end',
StateChange = 'state-change',
PlayBack = 'play-back',
Destroy = 'destroy',
Expand Down

0 comments on commit 4dded10

Please sign in to comment.