Skip to content

Commit e25943a

Browse files
committed
Expose as _onExecutionProgress
1 parent c95a6bf commit e25943a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/duckdb-wasm/src/log.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ export type ProgressEntry = {
4747
readonly repetitions: string;
4848
}
4949

50+
/** An execution progress handler */
51+
export type ExecutionProgressHandler = (p: ProgressEntry) => void;
52+
5053
export type LogEntryVariant =
5154
| LogEntry<LogOrigin.BINDINGS, LogTopic.INSTANTIATE, LogEvent.ERROR, string>
5255
| LogEntry<LogOrigin.BINDINGS, LogTopic.QUERY, LogEvent.START, void>

packages/duckdb-wasm/src/parallel/async_bindings.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { InstantiationProgress } from '../bindings/progress';
1818
import { arrowToSQLField } from '../json_typedef';
1919
import { WebFile } from '../bindings/web_file';
2020
import { DuckDBDataProtocol } from '../bindings';
21+
import { ProgressEntry } from '../log';
2122

2223
const TEXT_ENCODER = new TextEncoder();
2324

@@ -33,7 +34,7 @@ export class AsyncDuckDB implements AsyncDuckDBBindings {
3334
protected _onInstantiationProgress: ((p: InstantiationProgress) => void)[] = [];
3435

3536
/** Progress callbacks */
36-
//protected _onProgressCallback: ((p: InstantiationProgress) => void)[] = [];
37+
protected _onExecutionProgress: ((p: ProgressEntry) => void)[] = [];
3738

3839
/** The logger */
3940
protected readonly _logger: Logger;
@@ -126,7 +127,9 @@ export class AsyncDuckDB implements AsyncDuckDBBindings {
126127
switch (response.type) {
127128
// Request failed?
128129
case WorkerResponseType.PROGRESS_UPDATE: {
129-
console.log(response.data);
130+
for (const p of this._onExecutionProgress) {
131+
p(response.data);
132+
}
130133
return;
131134
}
132135
case WorkerResponseType.LOG: {

0 commit comments

Comments
 (0)