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

Function startAutoLoad

src/persisters/common/create.ts:234–260  ·  view source on GitHub ↗
(
    initialContent?: Content | (() => Content),
  )

Source from the content-addressed store, hash-verified

232 };
233
234 const startAutoLoad = async (
235 initialContent?: Content | (() => Content),
236 ): Promise<Persister<Persist>> => {
237 stopAutoLoad();
238 await load(initialContent);
239 await tryCatch(
240 async () =>
241 (autoLoadHandle = await addPersisterListener(
242 async (content, changes) => {
243 if (changes || content) {
244 /*! istanbul ignore else */
245 if (status != StatusValues.Saving) {
246 setStatus(StatusValues.Loading);
247 loads++;
248 setContentOrChanges(changes ?? content);
249 setStatus(StatusValues.Idle);
250 await saveAfterMutated();
251 }
252 } else {
253 await load();
254 }
255 },
256 )),
257 onIgnoredError,
258 );
259 return persister;
260 };
261
262 const stopAutoLoad = async (): Promise<Persister<Persist>> => {
263 if (autoLoadHandle) {

Callers

nothing calls this directly

Calls 7

tryCatchFunction · 0.90
stopAutoLoadFunction · 0.70
loadFunction · 0.70
setStatusFunction · 0.70
setContentOrChangesFunction · 0.70
saveAfterMutatedFunction · 0.70
addPersisterListenerFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…