MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / createLoadingState

Function createLoadingState

packages/core/src/widgets/tree.ts:396–417  ·  view source on GitHub ↗
(initial: readonly string[] = [])

Source from the content-addressed store, hash-verified

394 * @returns LoadingState object
395 */
396export function createLoadingState(initial: readonly string[] = []): LoadingState {
397 const loading = new Set(initial);
398
399 const state: LoadingState = Object.freeze({
400 loading: loading as ReadonlySet<string>,
401 startLoading: (key: string): LoadingState => {
402 if (loading.has(key)) {
403 return state;
404 }
405 return createLoadingState([...loading, key]);
406 },
407 finishLoading: (key: string): LoadingState => {
408 if (!loading.has(key)) {
409 return state;
410 }
411 return createLoadingState([...loading].filter((k) => k !== key));
412 },
413 isLoading: (key: string): boolean => loading.has(key),
414 });
415
416 return state;
417}
418
419/* ========== Expand/Collapse Indicators ========== */
420

Callers 2

tree.lazy.test.tsFile · 0.85

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected