communication.js 638 B

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