@@ -266,24 +266,37 @@ impl<R: Runtime> Window<R> {
266266 & self . window . label
267267 }
268268
269- /// Emits an event to the current window.
269+ /// Emits an event to both the JavaScript and the Rust listeners.
270+ pub fn emit_and_trigger < S : Serialize > ( & self , event : & str , payload : S ) -> crate :: Result < ( ) > {
271+ self . trigger ( event, Some ( serde_json:: to_string ( & payload) ?) ) ;
272+ self . emit ( event, payload)
273+ }
274+
275+ /// Emits an event to the JavaScript listeners on the current window.
276+ ///
277+ /// The event is only delivered to listeners that used the `appWindow.listen` method on the @tauri-apps/api `window` module.
270278 pub fn emit < S : Serialize > ( & self , event : & str , payload : S ) -> crate :: Result < ( ) > {
271279 self . eval ( & format ! (
272280 "window['{}']({{event: {}, payload: {}}})" ,
273281 self . manager. event_emit_function_name( ) ,
274282 serde_json:: to_string( event) ?,
275283 serde_json:: to_value( payload) ?,
276284 ) ) ?;
277-
278285 Ok ( ( ) )
279286 }
280287
281- /// Emits an event on all windows except this one.
288+ /// Emits an event to the JavaScript listeners on all windows except this one.
289+ ///
290+ /// The event is only delivered to listeners that used the `appWindow.listen` function from the `@tauri-apps/api `window` module.
282291 pub fn emit_others < S : Serialize + Clone > ( & self , event : & str , payload : S ) -> crate :: Result < ( ) > {
283292 self . manager . emit_filter ( event, payload, |w| w != self )
284293 }
285294
286295 /// Listen to an event on this window.
296+ ///
297+ /// This listener only receives events that are triggered using the
298+ /// [`trigger`](Window#method.trigger) and [`emit_and_trigger`](Window#method.emit_and_trigger) methods or
299+ /// the `appWindow.emit` function from the @tauri-apps/api `window` module.
287300 pub fn listen < F > ( & self , event : impl Into < String > , handler : F ) -> EventHandler
288301 where
289302 F : Fn ( Event ) + Send + ' static ,
@@ -297,7 +310,7 @@ impl<R: Runtime> Window<R> {
297310 self . manager . unlisten ( handler_id)
298311 }
299312
300- /// Listen to a an event on this window a single time.
313+ /// Listen to an event on this window a single time.
301314 pub fn once < F > ( & self , event : impl Into < String > , handler : F ) -> EventHandler
302315 where
303316 F : Fn ( Event ) + Send + ' static ,
@@ -306,7 +319,9 @@ impl<R: Runtime> Window<R> {
306319 self . manager . once ( event. into ( ) , Some ( label) , handler)
307320 }
308321
309- /// Triggers an event on this window.
322+ /// Triggers an event to the Rust listeners on this window.
323+ ///
324+ /// The event is only delivered to listeners that used the [`listen`](Window#method.listen) method.
310325 pub fn trigger ( & self , event : & str , data : Option < String > ) {
311326 let label = self . window . label . clone ( ) ;
312327 self . manager . trigger ( event, Some ( label) , data)
0 commit comments