You have to explicitly call subscription.unsubscribe() in order for the workers to be torn down. In other words, this:
runWorker() { const input$: Observable<string> = of('hello'); fromWorker<string, string>( () => new Worker(new URL('./app.worker', import.meta.url), { type: 'module' }), input$ ).subscribe((message) => { console.log(`Got message`, message); });
Really needs to be this:
subscription = new Subscription(); runWorker() { const input$: Observable<string> = of('hello'); this.subscription.add(fromWorker<string, string>( () => new Worker(new URL('./app.worker', import.meta.url), { type: 'module' }), input$ ).subscribe((message) => { console.log(`Got message`, message); ==> this.subscription.unsubscribe(); <== }) );
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You have to explicitly call subscription.unsubscribe() in order for the workers to be torn down. In other words, this:
Really needs to be this: