Offload CPU Work to a Web Worker (Progress + Cancel)
Keep the UI responsive by moving CPU-heavy work off the main thread using a Web Worker. This snippet creates an inli...
<script setup lang="ts">
import { computed, onUnmounted, ref } from 'vue';
type WorkerInMessage =
| { type: 'start'; n: number; chunkSize: number }
| { type: 'cancel' };
type WorkerOutMessage =