Skip to content

Commit 21b5fac

Browse files
committed
Cleanup
1 parent 1ba65f0 commit 21b5fac

File tree

22 files changed

+58
-137
lines changed

22 files changed

+58
-137
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# CLI Example
22

3-
This is a minimal Rust CLI that starts the Elixir app in `src-elixir`, sends `ping`, and prints `pong`.
3+
## Usage
4+
5+
```sh
6+
cargo run
7+
```

elixirkit_next/examples/cli_example/src-elixir/lib/example.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ defmodule Example.Server do
2020

2121
@impl true
2222
def init(_) do
23-
{:ok, pid} = ElixirKit.start()
23+
{:ok, pid} = ElixirKit.start_link()
2424
ref = Process.monitor(pid)
2525

2626
ElixirKit.publish("ready", "ready")

elixirkit_next/examples/cli_example/src-elixir/mix.exs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,22 @@ defmodule Example.MixProject do
55
[
66
app: :example,
77
version: "0.1.0",
8-
elixir: "~> 1.19",
8+
elixir: "~> 1.18",
99
start_permanent: Mix.env() == :prod,
1010
deps: deps()
1111
]
1212
end
1313

14-
# Run "mix help compile.app" to learn about applications.
1514
def application do
1615
[
1716
extra_applications: [:logger],
1817
mod: {Example.Application, []}
1918
]
2019
end
2120

22-
# Run "mix help deps" to learn about dependencies.
2321
defp deps do
2422
[
25-
{:elixirkitnext, path: "../../.."}
23+
{:elixirkit, path: "../../.."}
2624
]
2725
end
2826
end
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
# Tauri Example (Elixir)
1+
# Tauri Example
22

3-
This application connects to the Tauri shell via ElixirKit and responds to `ping` with `pong`.
3+
```sh
4+
cargo tauri dev
5+
```
Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,48 @@
1-
defmodule Example do
2-
@moduledoc """
3-
Documentation for `Example`.
4-
"""
1+
defmodule Example.Application do
2+
@moduledoc false
53

6-
@doc """
7-
Hello world.
4+
use Application
85

9-
## Examples
6+
@impl true
7+
def start(_type, _args) do
8+
children = [
9+
Example.Server
10+
]
1011

11-
iex> Example.hello()
12-
:world
12+
opts = [strategy: :one_for_one, name: Example.Supervisor]
13+
Supervisor.start_link(children, opts)
14+
end
15+
end
16+
17+
defmodule Example.Server do
18+
@moduledoc false
19+
20+
use GenServer
21+
22+
def start_link(arg) do
23+
GenServer.start_link(__MODULE__, arg, name: __MODULE__)
24+
end
25+
26+
@impl true
27+
def init(_) do
28+
{:ok, pid} = ElixirKit.start_link()
29+
ref = Process.monitor(pid)
30+
31+
ElixirKit.publish("ready", "ready")
32+
33+
{:ok, %{ref: ref}}
34+
end
35+
36+
@impl true
37+
def handle_info({:event, "ping", "ping"}, state) do
38+
IO.puts("[elixir] ping")
39+
ElixirKit.publish("echo", "pong")
40+
{:noreply, state}
41+
end
1342

14-
"""
15-
def hello do
16-
:world
43+
@impl true
44+
def handle_info({:DOWN, ref, :process, _, :shutdown}, state) when ref == state.ref do
45+
System.stop()
46+
{:stop, :shutdown, state}
1747
end
1848
end

elixirkit_next/examples/tauri_example/src-elixir/lib/example/application.ex

Lines changed: 0 additions & 19 deletions
This file was deleted.

elixirkit_next/examples/tauri_example/src-elixir/lib/example/server.ex

Lines changed: 0 additions & 33 deletions
This file was deleted.

elixirkit_next/examples/tauri_example/src-elixir/mix.exs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,22 @@ defmodule Example.MixProject do
55
[
66
app: :example,
77
version: "0.1.0",
8-
elixir: "~> 1.19",
8+
elixir: "~> 1.18",
99
start_permanent: Mix.env() == :prod,
1010
deps: deps()
1111
]
1212
end
1313

14-
# Run "mix help compile.app" to learn about applications.
1514
def application do
1615
[
1716
extra_applications: [:logger],
1817
mod: {Example.Application, []}
1918
]
2019
end
2120

22-
# Run "mix help deps" to learn about dependencies.
2321
defp deps do
2422
[
25-
{:elixirkitnext, path: "../../.."}
23+
{:elixirkit, path: "../../.."}
2624
]
2725
end
2826
end
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)