re-use live mode config - and improve docs on how to start liveMode (#1003)

* Use config.liveMode to turn on liveMode in the timer

* Discussion of `startLive(1500)` was incorrect as startLive is based on timestamps, not playback offsets.  Also reorder to introduce `addEvent` earlier

Co-authored-by: Eoghan Murray <eoghan@getthere.ie>
This commit is contained in:
Justin Halsall
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 268229b8b3
commit b9516a2759
3 changed files with 28 additions and 13 deletions

View File

@@ -262,7 +262,10 @@ export class Replayer {
this.mirror.reset();
});
const timer = new Timer([], config?.speed || defaultConfig.speed);
const timer = new Timer([], {
speed: this.config.speed,
liveMode: this.config.liveMode,
});
this.service = createPlayerService(
{
events: events

View File

@@ -13,9 +13,16 @@ export class Timer {
private raf: number | null = null;
private liveMode: boolean;
constructor(actions: actionWithDelay[] = [], speed: number) {
constructor(
actions: actionWithDelay[] = [],
config: {
speed: number;
liveMode: boolean;
},
) {
this.actions = actions;
this.speed = speed;
this.speed = config.speed;
this.liveMode = config.liveMode;
}
/**
* Add an action after the timer starts.