Skip to content

Commit 1a7cf79

Browse files
committed
cleanup
1 parent 17454b6 commit 1a7cf79

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

content/blog/2024/11-14-bevy-channel-trigger/index.md renamed to content/blog/2024/11-15-bevy-channel-trigger/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
+++
2-
title = "Extending Bevy with C: Communicating via FFI"
3-
date = 2024-11-14
2+
title = "Sending Events to Bevy from anywhere"
3+
date = 2024-11-15
44
[extra]
55
tags=["rust","bevy","gamedev"]
66
hidden = true
7-
custom_summary = "We released the bevy_channel_trigger crate to simplify communication between Bevy and foreign libraries or languages."
7+
custom_summary = "We released the bevy_channel_trigger crate to simplify communication from foreign libraries or languages to Bevy."
88
+++
99

1010
In this short post we introduce the recently released [bevy_channel_trigger](https://crates.io/crates/bevy_channel_trigger) crate, why we need it to talk to foreign code and what it sets it apart from alternatives. If you just want to start using it, find it on [GitHub](https://github.com/rustunit/bevy_channel_trigger).
@@ -23,10 +23,14 @@ You can just call foreign functions of course right from your Bevy Systems but t
2323

2424
This is where channels like [crossbeam](https://github.com/crossbeam-rs/crossbeam), [async-channel](https://docs.rs/async-channel/latest/async_channel/) or [flume](https://github.com/zesterer/flume) come in handy to communicate back into our Bevy game logic.
2525

26-
Lets look at an example.
26+
Lets look at a very simple example.
2727

2828
# Show me an example
2929

30+
The this example we show how to define an Event type `MyEvent` (line **2**)
31+
that we want to send as a reaction to a foreign function calling us
32+
(via callbacks or whatever the mechanism).
33+
3034
```rust,linenos
3135
#[derive(Event)]
3236
struct MyEvent(i32);
@@ -58,10 +62,6 @@ fn main() {
5862
}
5963
```
6064

61-
The above example shows how we define an Event type `MyEvent` (line **2**)
62-
that we want to send as a reaction to a foreign function calling us
63-
(via callbacks or whatever the mechanism).
64-
6565
For the purposes of this example we simulate this by spinning off a
6666
separate thread (line **14**) and passing `sender` into it. Since this is
6767
a multiple-producers-single-consumer channel we can clone the sender

content/blog/2024/11-14-bevy-channel-trigger/schema.png renamed to content/blog/2024/11-15-bevy-channel-trigger/schema.png

File renamed without changes.

docs/blog/2024/11-14-bevy-channel-trigger/index.html renamed to docs/blog/2024/11-15-bevy-channel-trigger/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
</header>
2424

2525
<div id="blogpage">
26-
<div class="date">2024-11-14</div>
26+
<div class="date">2024-11-15</div>
2727

2828
<div class="hidden">hidden</div>
2929

3030
<h1 class="title">
31-
Extending Bevy with C: Communicating via FFI
31+
Sending Events to Bevy from anywhere
3232
</h1>
3333
<div class="content">
3434
<p>In this short post we introduce the recently released <a href="https://crates.io/crates/bevy_channel_trigger">bevy_channel_trigger</a> crate, why we need it to talk to foreign code and what it sets it apart from alternatives. If you just want to start using it, find it on <a href="https://github.com/rustunit/bevy_channel_trigger">GitHub</a>.</p>
@@ -42,8 +42,11 @@ <h1 id="why">Why?</h1>
4242
</ul>
4343
<p>You can just call foreign functions of course right from your Bevy Systems but that is often not a good idea as we don't want to block our game logic. Often these APIs are async as well which means they will produce a result sometime later that we then want to receive back in our Bevy Systems. The schema on the right visualizes this.</p>
4444
<p>This is where channels like <a href="https://github.com/crossbeam-rs/crossbeam">crossbeam</a>, <a href="https://docs.rs/async-channel/latest/async_channel/">async-channel</a> or <a href="https://github.com/zesterer/flume">flume</a> come in handy to communicate back into our Bevy game logic.</p>
45-
<p>Lets look at an example.</p>
45+
<p>Lets look at a very simple example.</p>
4646
<h1 id="show-me-an-example">Show me an example</h1>
47+
<p>The this example we show how to define an Event type <code>MyEvent</code> (line <strong>2</strong>)
48+
that we want to send as a reaction to a foreign function calling us
49+
(via callbacks or whatever the mechanism).</p>
4750
<pre data-linenos data-lang="rust" style="background-color:#212121;color:#eeffff;" class="language-rust "><code class="language-rust" data-lang="rust"><table><tbody><tr><td>1</td><td><span style="color:#89ddff;">#[</span><span>derive</span><span style="color:#89ddff;">(</span><span>Event</span><span style="color:#89ddff;">)]
4851
</span></td></tr><tr><td>2</td><td><span style="font-style:italic;color:#c792ea;">struct </span><span>MyEvent</span><span style="color:#89ddff;">(</span><span style="font-style:italic;color:#c792ea;">i32</span><span style="color:#89ddff;">);
4952
</span></td></tr><tr><td>3</td><td><span>
@@ -73,9 +76,6 @@ <h1 id="show-me-an-example">Show me an example</h1>
7376
</span></td></tr><tr><td>27</td><td><span> app</span><span style="color:#89ddff;">.</span><span style="color:#82aaff;">run</span><span style="color:#89ddff;">();
7477
</span></td></tr><tr><td>28</td><td><span style="color:#89ddff;">}
7578
</span></td></tr></tbody></table></code></pre>
76-
<p>The above example shows how we define an Event type <code>MyEvent</code> (line <strong>2</strong>)
77-
that we want to send as a reaction to a foreign function calling us
78-
(via callbacks or whatever the mechanism).</p>
7979
<p>For the purposes of this example we simulate this by spinning off a
8080
separate thread (line <strong>14</strong>) and passing <code>sender</code> into it. Since this is
8181
a multiple-producers-single-consumer channel we can clone the sender
File renamed without changes.

docs/sitemap.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<lastmod>2024-10-21</lastmod>
1616
</url>
1717
<url>
18-
<loc>https://rustunit.com/blog/2024/11-14-bevy-channel-trigger/</loc>
19-
<lastmod>2024-11-14</lastmod>
18+
<loc>https://rustunit.com/blog/2024/11-15-bevy-channel-trigger/</loc>
19+
<lastmod>2024-11-15</lastmod>
2020
</url>
2121
<url>
2222
<loc>https://rustunit.com/blog/2024/hello-world/</loc>

0 commit comments

Comments
 (0)