You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
imo it would be nice to get also the event system typed. Any plans or ideas for that?
At the moment a possible solution is to use specta to create at least the typescript types automatically. But you can still misspell the event identifiers. I also rly like the idea of the .wit files.
Thanks for your great work!
The text was updated successfully, but these errors were encountered:
Yeah so the way I plan to bring this to tauri-bindgen is through something completely different: streams.
This is essentially the same as in GRPC if you're familiar with that, if not here's the gist:
On the guest side this would map to AsyncIterator for JS and SomeSpecificStreamType<String> for Rust probably.
So no events in the classical tauri sense (imo superior though bc it forces cleaner code) but I hope it can fulfill all the use cases.
Edit: If you want a similar behavior to events right now under this stream model you'd use an tokio::sync::mpsc channel like so:
structLogData{rx: mpsc::Receiver<String>}implLogforLogData{typeStartLoggingStream = Pin<Box<tokio_stream::wrappers::ReceiverStream<String>>>;fnstart_logging(&self) -> Result<Self::StartLoggingStream>{let rx = todo!();// haven't figured out how to do this yetlet stream = tokio_stream::wrappers::ReceiverStream::new(rx);Ok(Box::pin(stream))}}
And now you can use the mpsc::Sender handles across the codebase like you'd call win.emit() (but with more safety)
imo it would be nice to get also the event system typed. Any plans or ideas for that?
At the moment a possible solution is to use specta to create at least the typescript types automatically. But you can still misspell the event identifiers. I also rly like the idea of the
.wit
files.Thanks for your great work!
The text was updated successfully, but these errors were encountered: