-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(tauri/Emitter): add emit_str*
method to emit serialized data
#12460
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
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.
this feels more like emit_str
than emit_json
, let's rename
crates/tauri/src/event/mod.rs
Outdated
let _span = tracing::debug_span!("window::emit::json").entered(); | ||
Ok(EmitArgs { | ||
event_name: event.into(), | ||
event: serde_json::to_string(event)?, |
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.
let's remove this serde call as well, it is unnecessary, also do the same for EmitArgs::new
.
Don't forget to update emit_js_script
function later down in this file to add wrapping single quotes around event name.
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.
let's remove this serde call as well, it is unnecessary, also do the same for EmitArgs::new.
I don't quite understand, do you mean event: event.into()
? If so, wouldn't event_name
and event
be the same?
Don't forget to update emit_js_script function later down in this file to add wrapping single quotes around event name.
Wouldn't this cause issues with escaping "
and '
?
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.
it shouldn't be an issue because event names are validated to contain alphanumeric, -
, /
, :
and _
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.
we can remove the event_name
as well, seems uneeded.
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.
Done. I call it a day. If there are any other changes needed, I will handle them tomorrow; or feel free to push to this PR.
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.
Thank you, I will wait on #12444 first before we can move forward with this PR as it touches the same code
Bb. Bb
…On Tue, Jan 21, 2025, 8:04 PM Amr Bashir ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In crates/tauri/src/event/mod.rs
<#12460 (comment)>:
> @@ -141,6 +141,16 @@ impl EmitArgs {
payload: serde_json::to_string(&payload)?,
})
}
+
+ pub fn new_json(event: &str, payload: String) -> crate::Result<Self> {
+ #[cfg(feature = "tracing")]
+ let _span = tracing::debug_span!("window::emit::json").entered();
+ Ok(EmitArgs {
+ event_name: event.into(),
+ event: serde_json::to_string(event)?,
let's remove this serde call as well, it is unnecessary, also do the same
for EmitArgs::new.
Don't forget to update emit_js_script function later down in this file to
add wrapping single quotes around event name.
—
Reply to this email directly, view it on GitHub
<#12460 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3PBZEMKDXDYOXIW4XSDG5T2LZOYJAVCNFSM6AAAAABVRVDL22VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKNRUHEYDKNJXGI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Package Changes Through 43c993eThere are 7 changes which include tauri-cli with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri with minor, @tauri-apps/api with minor, @tauri-apps/cli with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
#12444 is now merged, we can move on with this PR once you fix the conflicts |
will do it now |
@amrbashir. Sorry for pinging you, could you please review this PR? I noticed that It's okay if you don't have time right now. I can postpone this feature to |
No worries, 2.3 still needs a few days/weeks. I just started merging minor PRs for it. I also asked Amr to not merge yours until now (because I wanted to release patches first) so this is on me :) |
emit_json*
method to emit serialized dataemit_str*
method to emit serialized data
close #12459