-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat(core): add IPC channel #6813
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this mobile only feature?
I've also implemented it for desktop (it can easily be backported to v1) though the main idea here is to use it to send events from the Kotlin and Swift sides to the webview (eventually we'll also need a communication channel between mobile and Rust, but that's a little complicated since it involves static variables). |
Is this part of the public API? |
Yeah it is part of the public API @JonasKruckenberg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fully up to date with mobile, but I see what you are trying to do with the channel communication here.
Only suggestion would be to cut the channel prefix once, instead of splitting on the string and grabbing the second.
Can we hold off on merging this until I had the chance to review it tomorrow? |
Sure @JonasKruckenberg |
core/tauri/src/api/ipc.rs
Outdated
if value.starts_with(CHANNEL_PREFIX) { | ||
let callback_id: Option<usize> = value | ||
.chars() | ||
.skip(CHANNEL_PREFIX.len()) | ||
.collect::<String>() | ||
.parse() | ||
.ok(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use value.split_once(CHANNEL_PREFIX)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed.
tooling/api/src/tauri.ts
Outdated
@@ -55,6 +55,29 @@ function transformCallback( | |||
return identifier | |||
} | |||
|
|||
class Channel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would refactor this to be more similar to the Websocket
or BroadcastChannel
api i.e. the constructor takes no arguments and you can listen to events by overriding the on message
property or calling .addEventListener('message', () => {})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, pushed.
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___
)Other information