#Listen in typescript and call from rust

29 messages · Page 1 of 1 (latest)

night galleon
#

Is it possible to listen to a event from rust in typescript ? I know i can invoke rust code from typescript but how can i do the reverse. I didn't find anything useful. Basically when i open the window from rust i want to call that function and focus the input box. Simple as that

junior solar
night galleon
junior solar
night galleon
#

using vue it crashes xd

#

and i cant even see the log lmao

#

i have this:

const focusInput = await listen<string>("focus", (event) => {
  console.log("Entrou no input")
})
junior solar
#

what crashed? backend or only frontend?

night galleon
#

frontend i think

#

main_window.emit("focus", "").unwrap();

junior solar
#

so window still exists?

night galleon
#

hm maybe i should unhide to debug this. it starts hidden by default

#

stays on the tray

junior solar
#

or listen after unhide

night galleon
#

3 days on the same app has been killing me lmao

#

cant even do simple things

#

@proud latch @visual grotto have you ever needed to do this? The only place that its not crashing is onMounted but then it's not listenting. The console.log won't trigger

#

and the window crashes otherwise

visual grotto
visual grotto
#
  async mounted() {
    const self = this
    self.unlisten = await listen('system_state_update', (event) => {
      self.systemState = event.payload
    })
    await invoke('setup')
  }
night galleon
#

lmao

visual grotto
#

Always love when that happens x)

night galleon
#

i created a const with a ref this time

#

instead of creating it onmount

#

probably that was it