wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.39k stars 1.23k forks source link

[v2] (quick fix) ReferenceError: Can't find variable: OnMultiple #1388

Closed lambdajack closed 2 years ago

lambdajack commented 2 years ago

Description

When calling EventsOn or EventsOnce (defined in frontend/wailsjs/runtime/runtime.js) on the frontend, they in turn make calls to OnMultiple which does not exist.

It should be EventsOnMultiple.

When manually changing runtime.js to use EventsOnMultiple the programme compiles and runs as expected. wails build works as expected if changing the file just before compilation.

wails dev rebuilds runtime.js when it detects changes. This causes any manual changes made to be effectively reversed and the functions go back to erroneously calling OnMultiple instead of EventsOnMultiple

Testing using wails init -n projectname -t vanilla-ts & ... react-ts & ... svelte-ts

To Reproduce

  1. wails init -n wailsisawesome -t react-ts
  2. wails dev
  3. (optional to test working change later) set up an event in the go backend (runtime.EventsEmit(...)) to fire every second emitting some data (I tested using a string)
  4. set up a frontend listener with EventsOn(...) in the already created App.tsx.

The app will fail to compile as the frontend cannot find OnMultiple.

  1. manually change ONLY the runtime.js file as described above (only this so as not to re-trigger an entire recompilation by wails dev which would override the manual changes.

The app now works as expected, receiving emitted events and corresponding data.

Expected behaviour

Calling OnEvents in the frontend should listen to events by correctly calling EventsOnMultiple instead of OnMultiple

Screenshots

No response

Attempted Fixes

When manually changing runtime.js to use EventsOnMultiple the programme compiles and runs as expected.

System Details

Wails CLI v2.0.0-beta.36

Scanning system - Please wait (this may take a long time)...Done.

System
------
OS:             Ubuntu
Version:        22.04
ID:             ubuntu
Go Version:     go1.18.1
Platform:       linux
Architecture:   amd64

Wails
------
Version:                v2.0.0-beta.36
Package Manager:        apt

Dependency      Package Name            Status          Version
----------      ------------            ------          -------
*docker         docker.io               Installed       20.10.14
gcc             build-essential         Installed       11.2.0
libgtk-3        libgtk-3-dev            Installed       3.24.33-1ubuntu1
libwebkit       libwebkit2gtk-4.0-dev   Installed       2.36.0-2ubuntu1
npm             npm                     Installed       8.9.0
*nsis           nsis                    Installed       v3.08-2
pkg-config      pkg-config              Installed       0.29.2

* - Optional Dependency

Diagnosis
---------
Your system is ready for Wails development!

If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony


### Additional context

_No response_
lambdajack commented 2 years ago

I am happy to make a fix and submit a pr for this - I am actively using Wails at the moment so would be glad to get it done as a priority.

leaanthony commented 2 years ago

It's already fixed on master 👍

lambdajack commented 2 years ago

Oh right.. Any chance you can post a link to the latest? I have pulled the master and it still has the old definitions? - am I looking in the wrong place?

leaanthony commented 2 years ago

This issue is driving me crazy. I swear I've fixed this twice already 🤣🤣 If you can get a PR in the next hour, I'll merge. If not I'll do it (again?) myself 👍

lambdajack commented 2 years ago

Haha - I've been there - PR on the way