RangerMauve / webrun

Run Web-first ESM modules outside of the browser
https://webrun-presentation.hashbase.io/
MIT License
77 stars 8 forks source link

Overhaul to be more OO #10

Closed RangerMauve closed 5 years ago

RangerMauve commented 5 years ago

I've rewritten a bunch of Webrun so that it's more OO and more plugin-friendly. Closes #7

RangerMauve commented 5 years ago

That's pretty much how it is! If you don't use Dat, then Dat won't take up the event loop and it'll exit normally.

The reason that loading a DatArchive or something from a Dat URL keeps the event loop alive is that it opens up a socket for replicating the content.

I'm 100% sure what the best approch is for this yet, so far I'm thinking that it'd make sense to count the number of places actively using a dat archive, and once it's no longer needed (using the .close() API), it'll stop replicating that archive. Once all archives are closed, I could stop the discovery swarm portion and have it woken up again after another DatArchive is loaded.

I don't think this needs to be addressed for this PR, however, so I think I'll leave it as a TODO for now.

RangerMauve commented 5 years ago

Changed how addGlobal behaves so that all globals that plugins add are lazy-loaded. 😀