Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ba3081

Browse files
committed
rename setLoading to setLoadingCallback for consistency
1 parent 33f7106 commit 2ba3081

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

packages/tadviewer/src/PivotRequester.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function getObjectDiff(obj1: any, obj2: any) {
217217
return diff;
218218
}
219219

220-
const noopSetLoading = (loading: boolean) => {};
220+
const noopSetLoadingCallback = (loading: boolean) => {};
221221

222222
/**
223223
* A PivotRequester listens for changes on the appState and viewport and
@@ -241,12 +241,12 @@ export class PivotRequester {
241241
pendingOffset: number;
242242
pendingLimit: number;
243243
errorCallback?: (e: Error) => void;
244-
setLoading: (loading: boolean) => void;
244+
setLoadingCallback: (loading: boolean) => void;
245245

246246
constructor(
247247
stateRef: oneref.StateRef<AppState>,
248248
errorCallback?: (e: Error) => void,
249-
setLoading?: (loading: boolean) => void
249+
setLoadingCallback?: (loading: boolean) => void
250250
) {
251251
this.pendingQueryRequest = null;
252252
this.currentQueryView = null;
@@ -255,7 +255,7 @@ export class PivotRequester {
255255
this.pendingOffset = 0;
256256
this.pendingLimit = 0;
257257
this.errorCallback = errorCallback;
258-
this.setLoading = setLoading || noopSetLoading;
258+
this.setLoadingCallback = setLoadingCallback || noopSetLoadingCallback;
259259

260260
addStateChangeListener(stateRef, (_) => {
261261
this.onStateChange(stateRef);
@@ -270,7 +270,7 @@ export class PivotRequester {
270270
stateRef: oneref.StateRef<AppState>,
271271
queryView: QueryView
272272
): Promise<PagedDataView> {
273-
this.setLoading(true);
273+
this.setLoadingCallback(true);
274274
const appState: AppState = mutableGet(stateRef);
275275
const viewState = appState.viewState;
276276
const viewParams = viewState.viewParams;
@@ -299,7 +299,7 @@ export class PivotRequester {
299299
.set("dataView", dataView) as ViewState
300300
)
301301
);
302-
this.setLoading(false);
302+
this.setLoadingCallback(false);
303303
return dataView;
304304
});
305305
return dreq;
@@ -377,7 +377,7 @@ export class PivotRequester {
377377
err.message,
378378
err.stack
379379
);
380-
this.setLoading(false);
380+
this.setLoadingCallback(false);
381381
// TODO:
382382
// remoteErrorDialog("Error constructing view", err.message); // Now let's try and restore to previous view params:
383383
oneref.update(
@@ -388,6 +388,10 @@ export class PivotRequester {
388388
.update("loadingTimer", (lt) => lt.stop())
389389
)
390390
);
391+
if (this.errorCallback) {
392+
this.errorCallback(err instanceof Error ? err : new Error(err));
393+
}
394+
391395
});
392396
const ltUpdater = util.pathUpdater<AppState, Timer>(stateRef, [
393397
"viewState",

packages/tadviewer/src/components/TadViewerPane.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ export interface TadViewerPaneProps {
5454
baseSqlQuery: string;
5555
dsConn: DataSourceConnection;
5656
errorCallback?: (e: Error) => void;
57-
setLoading: (loading: boolean) => void;
57+
setLoadingCallback: (loading: boolean) => void;
5858
}
5959

6060
export function TadViewerPane({
6161
baseSqlQuery,
6262
dsConn,
6363
errorCallback,
64-
setLoading,
64+
setLoadingCallback,
6565
}: TadViewerPaneProps): JSX.Element | null {
6666
const [appStateRef, setAppStateRef] = useState<StateRef<AppState> | null>(
6767
null
@@ -88,7 +88,7 @@ export function TadViewerPane({
8888
log.debug("*** initializing app state:");
8989
await initAppState(rtc, stateRef);
9090
log.debug("*** initialized Tad App state");
91-
const preq = new PivotRequester(stateRef, errorCallback, setLoading);
91+
const preq = new PivotRequester(stateRef, errorCallback, setLoadingCallback);
9292
log.debug("*** created pivotRequester");
9393
setPivotRequester(preq);
9494
log.debug("*** App component created and pivotrequester initialized");

0 commit comments

Comments
 (0)