Closed RangerMauve closed 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.
Changed how addGlobal
behaves so that all globals that plugins add are lazy-loaded. 😀
I've rewritten a bunch of Webrun so that it's more OO and more plugin-friendly. Closes #7
webrun
argument. They can do whatever they want to it from thereaddProtocol("protocol:", async (url) => String
to add a protocol handleraddGlobals((currentglobals) => newglobals)
in order to plug into the setup process where globals are being set up.self.close()
for stuff to be cleaned up. In the future we can probably get by with usingarchive.close()
on archives to clean up resources, and stopping the swarm when everything is done.cli arguments
functionality. Now if I runwebrun something.js --foo bar
it'll append?foo=bar
toimport.meta.url
. Closes #1self.postMessage
now stringifies content that isn't a string