-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yassen Damyanov
committed
Jul 20, 2021
1 parent
0259fed
commit f1fc588
Showing
4 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Makefile for tauri-events-minimal | ||
|
||
# Initialize the project after checkout | ||
init: | ||
yarn install | ||
yarn tauri deps install | ||
cd www && ln -s ../node_modules modules; cd .. | ||
|
||
# Clean the app build | ||
clean: | ||
cd src-tauri/ && rm -f Cargo.lock && cargo clean; cd .. | ||
|
||
# Remove cargo lock within the build target/ | ||
cargo-lock: | ||
@if [ -f src-tauri/target/debug/.cargo-lock ]; then \ | ||
echo ".cargo-lock exists, removing.." \ | ||
&& rm src-tauri/target/debug/.cargo-lock; \ | ||
else \ | ||
echo "(No .cargo-lock anyaway)"; \ | ||
fi | ||
|
||
# Start development server; build debug and run | ||
dev: cargo-lock | ||
yarn tauri dev | ||
|
||
|
||
.PHONY: init clean cargo-lock dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,76 @@ | ||
# tauri-events-minimal | ||
Minimal Tauri events example | ||
|
||
A Minimal Tauri events example to showcase an issue with pub/sub. | ||
|
||
Created following [the official guide]. | ||
|
||
## Download | ||
|
||
Simply clone this repository: | ||
|
||
``` | ||
$ git clone https://github.com/yassen-damyanov/tauri-events-minimal.git | ||
``` | ||
|
||
## Prerequisites | ||
|
||
- POSIX OS (Won't run on Windows because of a symlink used.) | ||
- rust + cargo | ||
- node + npm | ||
- yarn | ||
- make | ||
|
||
For rust + cargo and node + npm, see [Tauri's official installation docs], | ||
(see at the bottom for OS-specific instructions). | ||
|
||
|
||
## Initializaton | ||
|
||
Enter the repository root and do: | ||
|
||
``` | ||
$ make init | ||
``` | ||
|
||
## Running in dev mode | ||
|
||
Enter the repository root and do: | ||
|
||
``` | ||
$ make dev | ||
``` | ||
|
||
For a while you should see something like | ||
|
||
``` | ||
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... | ||
Compiling app v0.1.0 (/home/yassen/Work/public/tauri-events-minimal/src-tauri) | ||
Building [=======================> ] 379/380: app(bin) | ||
``` | ||
|
||
and then the app window would appear. | ||
|
||
## Check how it works | ||
|
||
- Open the dev tools of the app window (e.g. via right-click + 'Inspect Element') | ||
- Choose the 'Console' tab on bottom | ||
- Click "Send Event" | ||
|
||
What appears on the console: | ||
|
||
``` | ||
sendEvent() called | ||
onUserClick() called | ||
user-click | ||
{"message": "Mmmm ... Tauri looks good!"} | ||
``` | ||
|
||
which means that the front-end listener has intercepted the front-end `emit` | ||
call, not the back-end one. The rust back-end (in `src-tauri/src/main.rs`) | ||
does not seem to be involved at all. | ||
|
||
|
||
|
||
[the official guide]: https://tauri.studio/en/docs/usage/guides/events | ||
[Tauri's official installation docs]: https://tauri.studio/en/docs/getting-started/intro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.