communication.js 726 B

1234567891011121314151617181920212223242526
  1. document.getElementById("log").addEventListener("click", function () {
  2. console.log('log')
  3. window.__TAURI__.tauri.invoke({
  4. cmd: "logOperation",
  5. event: "tauri-click",
  6. payload: "this payload is optional because we used Option in Rust",
  7. });
  8. });
  9. document.getElementById("request").addEventListener("click", function () {
  10. window.__TAURI__.tauri
  11. .promisified({
  12. cmd: "performRequest",
  13. endpoint: "dummy endpoint arg",
  14. body: {
  15. id: 5,
  16. name: "test",
  17. },
  18. })
  19. .then(registerResponse)
  20. .catch(registerResponse);
  21. });
  22. document.getElementById("event").addEventListener("click", function () {
  23. window.__TAURI__.event.emit("js-event", "this is the payload string");
  24. });