From f1fc58880d45c49fe2686aa03ab29e8f5aa1968b Mon Sep 17 00:00:00 2001 From: Yassen Damyanov Date: Tue, 20 Jul 2021 18:53:17 +0300 Subject: [PATCH] Add Makefile and usable README --- Makefile | 27 +++++++++++++++ README.md | 76 +++++++++++++++++++++++++++++++++++++++++- src-tauri/rustfmt.toml | 2 +- www/modules | 1 - 4 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 Makefile delete mode 120000 www/modules diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7de4daa --- /dev/null +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 65ef5f6..d5965b6 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file diff --git a/src-tauri/rustfmt.toml b/src-tauri/rustfmt.toml index 16ef4db..c22f860 100644 --- a/src-tauri/rustfmt.toml +++ b/src-tauri/rustfmt.toml @@ -11,4 +11,4 @@ merge_derives = true use_try_shorthand = false use_field_init_shorthand = false force_explicit_abi = true -imports_granularity = "Crate" +# imports_granularity = "Crate" diff --git a/www/modules b/www/modules deleted file mode 120000 index 68a084a..0000000 --- a/www/modules +++ /dev/null @@ -1 +0,0 @@ -../node_modules \ No newline at end of file