#Do events only run once as of default?

5 messages · Page 1 of 1 (latest)

karmic glacier
#

i got a button that triggers an emit_all call on the frontend, that goes into a listener which emits a log signal on the frontend, but that only triggers once... What could it be?

eager idolBOT
#

Thank you for your message!

                1. Search the #1047150269156294677 forum for existing posts
                2. Search Github issues to see if this is a known issue
                3. Send the output of `tauri info`
                4. Provide reproduction steps for your issue
                5. Be polite and remember to follow the [Tauri Code of Conduct](https://github.com/tauri-apps/governance-and-guidance/blob/main/CODE_OF_CONDUCT.md)

                Once you've read this and taken the appropriate steps, react to this message
karmic glacier
#
yarn run v1.22.19
$ /Users/me/Desktop/Code/anime/node_modules/.bin/tauri info

[✔] Environment
    - OS: Mac OS 13.2.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.68.2 (9eb3afe9e 2023-03-27)
    ✔ Cargo: 1.68.2 (6feb7c9cf 2023-03-26)
    ✔ rustup: 1.25.2 (fae52a197 2023-02-01)
    ✔ Rust toolchain: stable-x86_64-apple-darwin (default)
    - node: 18.15.0
    - yarn: 1.22.19
    - npm: 9.5.0

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.2
    - @tauri-apps/api [NPM]: 1.3.0
    - @tauri-apps/cli [NPM]: 1.3.1

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../build
    - devPath: http://localhost:3000/
    - framework: React
✨  Done in 9.84s.
#

Reproduction steps:

  1. get a cra project, add tauri and stuff.
  2. inside ur index.js add this:
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { App } from './App';
import { listen } from '@tauri-apps/api/event';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
      <App />
  </React.StrictMode>
);

//Only this is new
listen("rust says", (event) => {
  let message = event.payload.message;
  console.log("Rust says: " + message)
})
  1. add a file in src, named whatever u want, mine is example.jsx:
import { emit, listen } from '@tauri-apps/api/event'
import React from 'react'

export default function Button() {
    function clickHandle() {
        emit("event 1", {
            "message": "Hello Rust, it's me, Javascript!"
        })
    }

    listen("event 3", (event) => {
        console.log("Yo, it's me Javascript")
    })

      return (
        <button onclick={clickHandle}>Click me!</button>
      )
}
  1. edit ur App.js:
export function App() {
  return (
    <div id={"app"} >
      <Button />
    </div>
  );
}
karmic glacier
#

btw didnt test but hope it works out, anyway its a minimal example of my situation