MCPcopy
hub / github.com/buildbot/buildbot / useDataApiDynamicQuery

Function useDataApiDynamicQuery

www/data-module/src/data/ReactUtils.ts:70–86  ·  view source on GitHub ↗
(
    dependency: any[], callback: () => Collection)

Source from the content-addressed store, hash-verified

68}
69
70export function useDataApiDynamicQuery<T, Collection extends IDataCollection>(
71 dependency: any[], callback: () => Collection): Collection {
72 const storedDependency = useRef<any[]>([]);
73 let storedCollection = useRef<Collection|null>(null);
74
75 if (storedCollection.current === null ||
76 !storedCollection.current.isValid() ||
77 !arrayElementsEqual(dependency, storedDependency.current)) {
78 if (storedCollection.current !== null) {
79 storedCollection.current.close();
80 }
81 storedCollection.current = callback();
82 storedDependency.current = [...dependency];
83 }
84
85 return storedCollection.current;
86}
87
88// The difference between this function and useDataApiDynamicQuery() is that
89// useDataApiDynamicQuery() will return empty collection whenever it is refreshed whereas

Callers 14

BuildSummary.tsxFile · 0.85
BuildersTable.tsxFile · 0.85
WorkersView.tsxFile · 0.85
ChangesView.tsxFile · 0.85
BuildView.tsxFile · 0.85
BuilderView.tsxFile · 0.85
WorkerView.tsxFile · 0.85

Calls 3

arrayElementsEqualFunction · 0.85
isValidMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected