From 963b03ab6e907fb5d19652b1a023621ff0ebfd21 Mon Sep 17 00:00:00 2001 From: Cole Lawrence Date: Mon, 1 Aug 2022 14:18:07 -0400 Subject: [PATCH] dev: Add warning for unbound .tick() call --- packages/dataverse/src/Ticker.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/dataverse/src/Ticker.ts b/packages/dataverse/src/Ticker.ts index 5bb3de6..7395b77 100644 --- a/packages/dataverse/src/Ticker.ts +++ b/packages/dataverse/src/Ticker.ts @@ -120,6 +120,13 @@ export default class Ticker { * @see onNextTick */ tick(t: number = performance.now()) { + if (process.env.NODE_ENV === 'development') { + if (!(this instanceof Ticker)) { + throw new Error( + 'ticker.tick must be called while bound to the ticker. As in, "ticker.tick(time)" or "requestAnimationFrame((t) => ticker.tick(t))" for performance.', + ) + } + } this._ticking = true this._timeAtCurrentTick = t for (const v of this._scheduledForNextTick) {