Я звоню GET API, который занимает более 22 -х годов из -за некоторого дорогого запроса DB от API. Мне нужно позвонить в этот API с помощью веб -работника. Вот мой текущий ngoninit
ngOnInit() {
this.fethDetails()
}
fetchDetails(){
this.serviceName.getList().subscribe({
next: (data) => {
this.siteLists = data;
},
error: (error) => {
console.log(error)
},
complete: () => {
console.log('complete')
}
})
}
///
addEventListener('message', ({ data }) => {
const response = // need to call fetchDetails();
postMessage(response);
});
if (typeof Worker !== 'undefined') {
// Create a new
const worker = new Worker(new URL('./report.worker', import.meta.url));
worker.onmessage = ({ data }) => {
console.log(`page got message: ${data}`);
};
worker.postMessage('hello');
} else {
// Web Workers are not supported in this environment.
// You should add a fallback so that your program still executes correctly.
}
Мне нужно позвонить в мою функцию fetchdetails () от работника, но не в состоянии вызвать ее ошибку.
addEventListener('message', ({ data }) => {
const reportData = // need to call fetchDetails(); //fetchDetails();
postMessage(reportData);
});
Подробнее здесь: https://stackoverflow.com/questions/795 ... in-angular
Позвоните веб -работнику из службы в Angular ⇐ Javascript
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение