From 203cec76e2d08738223f0654c45d7a2716ef858e Mon Sep 17 00:00:00 2001 From: Andrew Hyndman Date: Wed, 6 Sep 2023 17:09:35 -0400 Subject: [PATCH 1/2] getNetworkIdleObservable should not be called on import --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9423f20..5b596ed 100644 --- a/src/index.ts +++ b/src/index.ts @@ -101,7 +101,7 @@ export const cancel = (e?: Event) => calculator?.cancel(e); * For the most accurate results, `decrementAjaxCount` should be called * **exactly once** for each `incrementAjaxCount`. */ -export const incrementAjaxCount = getNetworkIdleObservable().incrementAjaxCount; +export const incrementAjaxCount = () => getNetworkIdleObservable().incrementAjaxCount(); /** * Call this to notify ttvc that an AJAX request has just resolved. @@ -112,4 +112,4 @@ export const incrementAjaxCount = getNetworkIdleObservable().incrementAjaxCount; * For the most accurate results, `decrementAjaxCount` should be called * **exactly once** for each `incrementAjaxCount`. */ -export const decrementAjaxCount = getNetworkIdleObservable().decrementAjaxCount; +export const decrementAjaxCount = () => getNetworkIdleObservable().decrementAjaxCount(); From a6b90d81d12fb18022aefd3accf114c8cecb4177 Mon Sep 17 00:00:00 2001 From: Andrew Hyndman Date: Fri, 13 Sep 2024 14:29:49 -0400 Subject: [PATCH 2/2] fix: init() should initialize network monitoring --- src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.ts b/src/index.ts index 5b596ed..71fe1fd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,6 +35,9 @@ export const init = (options?: TtvcOptions) => { Logger.info('init()'); + // initialize network monitoring + getNetworkIdleObservable(); + calculator = getVisuallyCompleteCalculator(); whenActivated(() => { void calculator.start();