feat(tauri/Emitter): add emit_str* method to emit serialized data#12460
feat(tauri/Emitter): add emit_str* method to emit serialized data#12460amrbashir merged 2 commits intotauri-apps:devfrom
emit_str* method to emit serialized data#12460Conversation
amrbashir
left a comment
There was a problem hiding this comment.
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.
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.
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.
it shouldn't be an issue because event names are validated to contain alphanumeric, -, /, : and _
There was a problem hiding this comment.
we can remove the event_name as well, seems uneeded.
There was a problem hiding this comment.
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.
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