Using RxJS to communicate with webworker in angular application.
const rxify = new RxifyWorker(new Worker('...'));
rxify.sendMessage('hello').subscribe(msg => console.log(msg));
const r = new RegisterWorker();
r.handleMessages((msg)=>{
const s = new Subject();
setTimeout(()=> {
s.next('Hello World!');
s.complete();
})
return s.asObservable();
});
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
https://naagarsuresh78.medium.com/rxify-webworker-communication-in-angular8-b0cddbdcf2e