mirror of
https://github.com/truewhile/MeBox.git
synced 2026-11-15 20:34:23 +08:00
14 lines
343 B
TypeScript
14 lines
343 B
TypeScript
/** Invalidates both successful and failed responses after a newer playback intent. */
|
|
export function createPlaybackRequestGuard() {
|
|
let generation = 0
|
|
return {
|
|
begin(): () => boolean {
|
|
const requested = ++generation
|
|
return () => requested === generation
|
|
},
|
|
invalidate(): void {
|
|
generation += 1
|
|
},
|
|
}
|
|
}
|