Skip to content

Commit

Permalink
add events
Browse files Browse the repository at this point in the history
refactor
  • Loading branch information
charlie632 committed Oct 18, 2024
1 parent 4dded10 commit 588634d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@ export class Replayer {
}

public playSingleEvent(eventIndex: number) {
const handleFinish = () => {
this.service.send('END');
this.emitter.off(ReplayerEvents.FlushEnd, handleFinish);
};
this.emitter.on(ReplayerEvents.FlushEnd, handleFinish);

if (this.service.state.matches('paused')) {
this.service.send({
type: 'PLAY_SINGLE_EVENT',
Expand Down
7 changes: 3 additions & 4 deletions packages/rrweb/src/replay/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function createPlayerService(
actions: ['recordTimeOffset', 'play'],
},
PLAY_SINGLE_EVENT: {
target: 'paused',
target: 'playing',
actions: ['playSingleEvent'],
},
CAST_EVENT: {
Expand Down Expand Up @@ -210,14 +210,13 @@ export function createPlayerService(

const { singleEvent } = event.payload;

const neededEvents2 = discardPriorSnapshotsToEvent(
const neededEvents = discardPriorSnapshotsToEvent(
ctx.events,
singleEvent,
);

applyEventsSynchronously(neededEvents2);
applyEventsSynchronously(neededEvents);
emitter.emit(ReplayerEvents.Flush);
// emitter.emit(ReplayerEvents.Finish);
},

play(ctx) {
Expand Down

0 comments on commit 588634d

Please sign in to comment.