I’d love to be able to define some worker code in a cell with these kinds of contents
<script id="workerCode">
function main() {
let result =[{x:5}]
return result
}
onmessage = function(oEvent) {
postMessage(main(oEvent.data));
};
</script>
And then have changes to that cells contents go on to trigger executions of other cells that make a worker with that script as src, and exchange messages with the worker.
This is possible if I create a named js cell containing either a string representation of source or html templated script with contents, but I lose the syntax highlighting, and auto formatting .
workerSrc = html`<script id="workerCode">
function main() {
let result =[{x:5}]
return result
}
onmessage = function(oEvent) {
postMessage(main(oEvent.data));
};
</script>`
Is there a way to make a notebook sensitive to changes in the contents of an html cell?