-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(core): refactor and fix event system following multiwebview support #8621
refactor(core): refactor and fix event system following multiwebview support #8621
Conversation
caeb9e8
to
57e3d43
Compare
…hub.com-tauri:tauri-apps/tauri into fix/window-close-requested-from-another-webview
I like how this simplifies the event system (most complex part of our system tbh.. even though it shouldn't be). But it changes a lot about the mental model when developing compared to v1. On v1 you treat the object that you can I'm fine with it (it's weird to me because I'm so used to the current approach but I can live with it and learn it) but this needs to be the last breaking change on this API. ever. And I'd like to get input from others @FabianLars @simonhyll |
Co-authored-by: Lucas Nogueira <[email protected]>
I have been also thinking about maybe adding a spec or a diagram of how the event system emits and listens to events but don't hold this PR on it, I can add it later when I get to it. |
I think it makes sense. It was quite messy before, and the event system (for us and the user) is indeed quite complicated so i like the explicitness in this approach. In v1 many people tripped up over the emit vs trigger approach and the current v2 version is a bit ambiguous. Looking at the diagram, one last thing that feels a bit meh is the listen_global api. I can't really put it into words (i'll try to later once my headache is gone lol), but maybe make the App/Handle an actual target too? I think we could then get rid of listen_global directly, or make it an "event sniffer" (that can listen to events no matter the target). |
That's what it currently does and should be kept that way IMO. Edit: actually no it doesn't sniff, let's make it a sniffer then
While we can definitely do this, and uses can use |
Alright, I have added |
I really like what you came up with, nice work! |
Looks amazing. I'm only wondering if we really need to keep the app/window/webview/webviewWindow emit and emit_to functions now that they all run the same logic. Having a single "entry point" for emitting events might be easier to understand and simplify migration too. |
They are all the same now, it is just a method on |
closes #8435