ashleyscirra / via.js Goto Github PK
View Code? Open in Web Editor NEWWrite JS code that runs in a different context. E.g. use the DOM in a Web Worker.
License: MIT License
Write JS code that runs in a different context. E.g. use the DOM in a Web Worker.
License: MIT License
Hi there!
I thought about outsourcing rendering of React components into web workers a lot last year, and there was one issue I couldn't really solve. It might help you to know about this limitation when accessing the DOM from within web workers :)
If the click handler resides in the web worker, then it will be invoked asynchronously. Unfortunately, due to its very nature, event.preventDefault()
and event.stopPropagation()
have to be called synchronously in order to work.
event.stopPropagation()
might be worked around by using event delegation, but I don't see a good solution for event.preventDefault()
. You could only highlight the DOM node / the event listener to always prevent default behavior, so the call happens immediately in the main thread. But a conditional preventDefault()
is then not possible.
Hope you can make some use of that!
Btw, keep me posted if you have a good idea how to approach this issue ๐
fetch()
is not defined in AudioWorkletGlobalScope
. Can via.js be used to execute fetch()
in AudioWorkletGlobalScope
?
@AshleyScirra What is the license for via.js? MIT? GPL?
I am using via.js in a React (CRA) context in order to do some DOM manipulation in web workers. In the docs we can see this example:
const document = via.document;
const button = document.createElement("button");
However, I cannot instance nor access any via
object with which to work. I am importing the four source files (receiver, controller, object, property). Probs I am missing something :)
Thanks!
If https://bugs.chromium.org/p/chromium/issues/detail?id=798855 is fixed, we should finally have a way to have cross-context communication without leaking memory. Try using this to reimplement via.js ready for production.
Hi !
I just stumbled upon your project, it looks cool. Never something I'll be allowed to use at work but definitely something I'd love to play with. Do you have any plans on updating it to use the new WeakMap and WeakSet objects? I see that you already reserved the space for it in WeakFactory and it doesn't seem too out there to implement!
Cheers
Do you have an example of how to load a blob of html/js/css into a virtual dom running in a web worker, but to then display the virtual DOM in the browser?
I assume this could be done by syncronising the virtual dom with a real DOM element?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.