Stlite Sharing: auto-save/run-as-you-type feature
whitphx opened this issue · 2 comments
whitphx commented
Stlite Sharing: auto-save/run-as-you-type feature
stevewillard commented
This is a great library - thank you! Is there an API to update the code for a running stlite app? I'm able to mount code, and I have a monaco editor, but when I change the code and .mount
again, I see the toasts, but the code doesn't change.
I noticed you have a save button here: https://edit.share.stlite.net/ and are able to detect code changes to reload the code. How can I do that?
whitphx commented
stlite.mount()
returns a controller object that has some methods to install packages and manipulate files on the virtual file system after mounting the app.
const controller = stlite.mount(
// ... options ...
);
await controller.install(["package1", "package2"]);
await controller.writeFile("path/to/file", "file content");
await controller.renameFile("old/path", "new/path");
await controller.unlink("path/to/file");
See the actual implementation for more details and available options.