mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-31 08:23:34 +00:00
test: add backend API contract coverage
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import type { SqlFileProgress } from "./tauri";
|
||||
|
||||
export function listenSqlFileProgressById(
|
||||
executionId: string,
|
||||
handler: (progress: SqlFileProgress) => void,
|
||||
): () => void {
|
||||
const es = new EventSource(`/api/sql-file/progress/${executionId}`);
|
||||
es.onmessage = (e) => {
|
||||
const progress: SqlFileProgress = JSON.parse(e.data);
|
||||
handler(progress);
|
||||
if (progress.status === "done" || progress.status === "error" || progress.status === "cancelled") {
|
||||
es.close();
|
||||
}
|
||||
};
|
||||
es.onerror = () => {
|
||||
es.close();
|
||||
};
|
||||
return () => es.close();
|
||||
}
|
||||
Reference in New Issue
Block a user