tomsun28 commented on code in PR #3668:
URL: https://github.com/apache/hertzbeat/pull/3668#discussion_r2280790746


##########
web-app/src/app/routes/monitor/monitor-data-chart/monitor-data-chart.worker.ts:
##########
@@ -0,0 +1,452 @@
+import { EChartsOption } from 'echarts';
+import { Observable } from 'rxjs';
+
+type WorkerParam = {
+  values: Record<string, any>;
+  isInterval?: boolean;
+};
+
+type WorkerResult = {
+  data?: EChartsOption;
+  progress: number;
+};
+// 创建在 Worker 中执行的 Observable
+function createWorker(data: WorkerParam): Observable<WorkerResult> {
+  return new Observable<WorkerResult>(subscriber => {
+    const worker = new Worker(fn2workerURL(), { name: 'xxxxx' });
+
+    // 发送数据到 Worker
+    worker.postMessage(data);
+
+    // 监听 Worker 消息
+    const messageHandler = (event: MessageEvent<WorkerResult>) => {
+      subscriber.next(event.data);
+      if (event.data.progress === 100) {
+        subscriber.complete();
+      }
+    };
+
+    const errorHandler = (error: ErrorEvent) => {
+      subscriber.error(error);
+    };
+
+    worker.addEventListener('message', messageHandler);
+    worker.addEventListener('error', errorHandler);
+
+    // 清理函数

Review Comment:
   hi please fix build error and use the english code comment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@hertzbeat.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@hertzbeat.apache.org
For additional commands, e-mail: notifications-h...@hertzbeat.apache.org

Reply via email to