MCPcopy Index your code
hub / github.com/tinyplex/tinybase / startPolling

Function startPolling

src/persisters/common/database/sqlite.ts:71–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69 let interval: number | NodeJS.Timeout;
70
71 const startPolling = () =>
72 (interval = startInterval(
73 () =>
74 tryCatch(async () => {
75 const [{d, s, c}] = (await executeCommand(
76 SELECT +
77 // eslint-disable-next-line max-len
78 ` ${DATA_VERSION} d,${SCHEMA_VERSION} s,TOTAL_CHANGES() c FROM ${PRAGMA}${DATA_VERSION} JOIN ${PRAGMA}${SCHEMA_VERSION}`,
79 )) as [IdObj<number>];
80 if (d != dataVersion || s != schemaVersion || c != totalChanges) {
81 if (!isNullish(dataVersion)) {
82 listener();
83 }
84 dataVersion = d;
85 schemaVersion = s;
86 totalChanges = c;
87 }
88 }),
89 autoLoadIntervalSeconds as number,
90 ));
91
92 const stopPolling = () => {
93 dataVersion = schemaVersion = totalChanges = null;

Callers 1

addPersisterListenerFunction · 0.85

Calls 3

startIntervalFunction · 0.90
tryCatchFunction · 0.90
isNullishFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…