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

Function load

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

Source from the content-addressed store, hash-verified

199 // --
200
201 const load = async (
202 initialContent?: Content | (() => Content),
203 ): Promise<Persister> => {
204 /*! istanbul ignore else */
205 if (status != StatusValues.Saving) {
206 setStatus(StatusValues.Loading);
207 loads++;
208 await schedule(async () => {
209 await tryCatch(
210 async () => {
211 const content = await getPersisted();
212 if (isArray(content)) {
213 setContentOrChanges(content);
214 } else if (isUndefined(content) && initialContent) {
215 setDefaultContent(initialContent);
216 } else if (!isUndefined(content)) {
217 errorNew(`Content is not an array: ${content}`);
218 }
219 },
220 (error) => {
221 onIgnoredError?.(error);
222 if (initialContent) {
223 setDefaultContent(initialContent);
224 }
225 },
226 );
227 setStatus(StatusValues.Idle);
228 await saveAfterMutated();
229 });
230 }
231 return persister;
232 };
233
234 const startAutoLoad = async (
235 initialContent?: Content | (() => Content),

Callers 1

startAutoLoadFunction · 0.70

Calls 10

tryCatchFunction · 0.90
isArrayFunction · 0.90
isUndefinedFunction · 0.90
errorNewFunction · 0.90
setStatusFunction · 0.70
scheduleFunction · 0.70
setContentOrChangesFunction · 0.70
saveAfterMutatedFunction · 0.70
getPersistedFunction · 0.50
setDefaultContentFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…