SergeyMell
Seroga.Mell
Sergey Melashych
sergey.mell@agilie.com
World
Software
CORE
CORE
CORE
CORE
api.post('/login', userData)
.then(response => {
// Success stuff
}, error => {
// Error stuff
});
// Other stuff
APP THREAD
Action 1
Action 2
Action 3
Waiting for the response
CORE
CORE
CORE
CORE
if (window.Worker) {
const myWorker = new Worker("hard_worker.js");
}
myWorker.postMessage(data);
myWorker.onmessage = (event) => {
console.log(event.data);
};
APP THREAD
WORKER THREAD
const myWorker =
new Worker("hard_worker.js");
myWorker.onmessage = ...
myWorker.postMessage(...);
renderResults(event.data);
self.onmessage = ...;
const result =
hardWork(event.data);
self.postMessage(result);
const sharedWorker = new SharedWorker("shared.js");
sharedWorker.port.addEventListener("message", event => {
// Subscribing Event
}, false);
sharedWorker.port.start();
sharedWorker.port.postMessage(data);
myWorker.postMessage(arrayOfData);
myWorker.postMessage(arrayOfData, [arrayOfData]);
let channel = new BroadcastChannel('channel-name');
channel.postMessage(data);
const sharedBuffer = new SharedArrayBuffer(40);
myWorker.postMessage(sharedBuffer);
this.$worker.run((arg) => {
return `Hello, ${arg}!`;
}, ['World'])
.then(result => {
console.log(result);
})
.catch(e => {
console.error(e);
});
https://github.com/israelss/vue-worker
https://github.com/web-perf/react-worker-dom
number of nodes
fps
react-renderer
react-worker-dom
UI THREAD
WORKER THREAD
Бизнес
логика
Пользовательское событие
postMessage('call');
Связанные данные
postMessage(data);
import '../polyfills.ts';
import '@angular/core';
import '@angular/common';
import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic';
import { AppModule } from '../app/app.module';
platformWorkerAppDynamic().bootstrapModule(AppModule);
bootstrapWorkerUi('../webworker.bundle.js');
import { WorkerAppModule } from '@angular/platform-webworker';
webworker.ts
main.ts
app.module.ts
@NgModule({
...,
providers: [
...,
{provide: APP_BASE_HREF, useValue: '/'},
WORKER_APP_LOCATION_PROVIDERS,
]
});
app.module.ts
bootstrapWorkerUi(
'../webworker.bundle.js',
WORKER_UI_LOCATION_PROVIDERS
);
main.ts
fps
интенсивность мутаций
Angular clean
Angular worker
SergeyMell
Seroga.Mell
Sergey Melashych
sergey.mell@agilie.com