tauri-apps / tauri-docs

The source for all Tauri project documentation.
https://tauri.app
MIT License
762 stars 536 forks source link

Events with YEW #952

Open memodyssey opened 1 year ago

memodyssey commented 1 year ago

Hello, I would like to implement the emit function with Yew but I don't how can I implement it especially the listen function https://tauri.app/v1/guides/features/events/

import { emit, listen } from '@tauri-apps/api/event'

// listen to the `click` event and get a function to remove the event listener
// there's also a `once` function that subscribes to an event and automatically unsubscribes the listener on the first event
const unlisten = await listen('click', (event) => {
  // event.event is the event name (useful if you want to use a single callback fn for multiple event types)
  // event.payload is the payload object
}

// emits the `click` event with the object payload
emit('click', {
  theMessage: 'Tauri is awesome!',
}) 

Is there any way to do this with a frontend built with rust ? Can we get this page documented with yew ?

simonhyll commented 10 months ago

This is the sort of thing that's the reason I really want us to take over the tauri-sys project, so we can offer the JS API in a nice manner to Rust based frontends as well.

Will track for 2.0.