Skip to content

Commit

Permalink
Add Makefile and usable README
Browse files Browse the repository at this point in the history
  • Loading branch information
Yassen Damyanov committed Jul 20, 2021
1 parent 0259fed commit f1fc588
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 3 deletions.
27 changes: 27 additions & 0 deletions Makefile
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
76 changes: 75 additions & 1 deletion README.md
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
2 changes: 1 addition & 1 deletion src-tauri/rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 0 additions & 1 deletion www/modules

This file was deleted.

0 comments on commit f1fc588

Please sign in to comment.