I’ve updated to v2, and so far everything is working well! I really like how things have gotten simpler with Lua.
However, I have some questions:
I’m very interested in the mq API, but it’s not clear how it works under the hood. I assume there should be a way to “register” subscribers to handle queued messages, but I haven’t been able to figure out how to do this with Lua—if it’s even possible.
My use case is to offload heavier operations to asynchronous processing, if that’s supported. For example, I’d like to queue some jobs on startup and have them processed asynchronously without blocking the main application. I tried using events for this, but they seem to run synchronously.
There appears to be a minor issue with either the datastore API or its documentation. The datastore doesn’t work as described on this page. It looks like the set method expects an array for the key argument, but the docs show a string being used. Passing a string throws an error.
This isn’t critical by any means, but I’m curious— is there a way to override or customize the UI by adding extra buttons or elements? Previously, this was somewhat possible using space-script along with some JavaScript and CSS selectors. The idea would be to extend the editor by hooking into the Silverbullet’s API and building custom modals, panels, or other UI components.
The way that it works is that it uses the local datastore (so in your client) to implement a message queue. Messages are processed asynchronously, but only when you have a client running.
This was primarily architected for plugs to you use, and isn’t really ready for Lua yet. It’s something I still need to get to. Probably I’ll set it up a bit differently, likely using the event listener mechanism for this too.
As to your use case: what do you mean with running synchronously? Either way, also message on the message queue are going to be run in the browser’s main thread. There’s no threading or workers being used here, so not sure what you’re trying to do is going to help.
Yes, I the API docs (that I AI generated) are wrong, I just pushed a fix for this. Should be live soon. Keys are lists of strings, not plain strings.
I’m not sure how I feel about this, but yes there is a way. Because using js.window in Lua you have access to browser’s window object, which gives you access to… well… everything.