By. Saad Abbasi
Details:
Skills:
🏃🏻♂️
🎮
I ❤️
1
1
Might change the way you write Web Apps
Event Queue
Call Stack
Async Tasks
💻
Events
-Jake Archibald's - Into the loop (JS Conf 2018)
But rather it boils down to concurrency and parallelism
Parallelism is about doing multiple things at once, while concurrency is about dealing with multiple things at once
- Rob Pike
Other Thread
Main Thread
/ ** Main Thread */
const worker =
new Worker('@scripts/worker.js');
worker.postMessage('Hey Kid');
worker.onmessage = (ev) => {
const msg = ev.data //'Hello Man'
console.log(msg);
};
worker.terminate();/ ** Separate Execution Env */
importScript('./scripts/fns');
// Methods/Objects/etc inside 'fns'
// - will be globally available
self.onmessage = e => {
const message = e.data;
console.log(message); // 'Hey Kid'
postMessage("Hello Man");
};
self.onclose = () => {
// Unsubscribe all the listeners
// Do needful before termination
}Web Workers
Service Workers
Animation Workerlets
Dedicated
Shared
Dedicated
worker
Keeps UI 60 FPS
Sync/ FPS Dropping Ops
(post)Message Channel
DW-3
DW-1
SW-1
Polling data Mappings & Transform
Maths & Statistics
Shared Operations
DW-MC
SW-MC
Timestamps may vary on different browsers
But sooner they will be ready to use in Production.
So, its very right time to learn it.
Thats pretty much it
{github, linkedin, *}/isaadabbasi
get connected