trying stuff
This commit is contained in:
parent
d329ccc4e3
commit
f1eaa83af5
3 changed files with 20 additions and 11 deletions
|
|
@ -65,15 +65,21 @@ self.onconnect = function (e) {
|
|||
var port = e.ports[0];
|
||||
allPorts.push(port);
|
||||
|
||||
allPorts.forEach((port) => {
|
||||
port.postMessage('yoooo');
|
||||
sendMessage('yooooo');
|
||||
|
||||
port.addEventListener('message', function (e) {
|
||||
// get the message sent to the worker
|
||||
|
||||
processMessage(e.data);
|
||||
});
|
||||
|
||||
port.start(); // Required when using addEventListener. Otherwise called implicitly by onmessage setter.
|
||||
};
|
||||
|
||||
self.onmessage = (message) => {
|
||||
const processMessage = (message) => {
|
||||
console.log(message);
|
||||
const { type, payload } = message;
|
||||
|
||||
switch (type) {
|
||||
case 'cpschange': {
|
||||
if (payload.cps !== cps) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue