Skip to content

Commit

Permalink
refactor: EmitArgs should keep EventName invariants
Browse files Browse the repository at this point in the history
  • Loading branch information
sftse committed Jan 23, 2025
1 parent 389c129 commit bdb733a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/tauri/src/event/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl Listeners {
{
let js_listeners = self.inner.js_event_listeners.lock().unwrap();
webviews.try_for_each(|webview| {
let event = &emit_args.event;
let event = emit_args.event.as_str();
if let Some(handlers) = js_listeners.get(webview.label()).and_then(|s| s.get(event)) {
let ids = handlers
.iter()
Expand Down
4 changes: 2 additions & 2 deletions crates/tauri/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl FromStr for EventTarget {
#[derive(Clone)]
pub struct EmitArgs {
/// Serialized event name.
event: String,
event: EventName,
/// Serialized payload.
payload: String,
}
Expand All @@ -189,7 +189,7 @@ impl EmitArgs {
#[cfg(feature = "tracing")]
let _span = tracing::debug_span!("window::emit::serialize").entered();
Ok(EmitArgs {
event: event.to_string(),
event: event.into_owned(),
payload: serde_json::to_string(payload)?,
})
}
Expand Down

0 comments on commit bdb733a

Please sign in to comment.