Layer 1 of 3 PROVIDER API
Make the timer provider replaceable.
A manager delegates timer creation and cancellation to a configurable provider. Its new tests check that calls reach the provider.
Attention points · 1
When can a provider change?
Check what happens to existing timer IDs if a different provider is installed after timers have started.
Files · 2
+ setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId {+ if (process.env.NODE_ENV !== 'production') {+ this.#providerCalled = true+ }+ return this.#provider.setTimeout(callback, delay)+ }++ clearTimeout(timeoutId: ManagedTimerId | undefined): void {+ this.#provider.clearTimeout(timeoutId)
Tests