Skip to content

Commit 72c4d9b

Browse files
committed
update port example
1 parent a0e60c1 commit 72c4d9b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

doc/api/esm.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -976,14 +976,14 @@ close normally.
976976
* and sends the message back to the application context
977977
*/
978978
export function globalPreload({ port }) {
979-
port.onmessage = (evt) => {
980-
port.postMessage(evt.data);
979+
port.on('message', (msg) => {
980+
port.postMessage(msg);
981981
};
982982
return `\
983983
port.postMessage('console.log("I went to the Loader and back");');
984-
port.onmessage = (evt) => {
985-
eval(evt.data);
986-
};
984+
port.on('message', (data) => {
985+
eval(data);
986+
});
987987
`;
988988
}
989989
```

0 commit comments

Comments
 (0)