File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ Various recipes for solving certain common scenarios.
44
55* [ Routing views] ( ./recipes/viewrouting.md )
66* [ Async] ( ./recipes/async.md )
7- * [ Themes] ( ./recipes/themes.md )
7+ * [ Themes] ( ./recipes/themes.md ) (not done yet)
Original file line number Diff line number Diff line change @@ -9,20 +9,24 @@ run the async code on a separate thread from the main thread.
99
1010## Setting up for async
1111
12- A function that starts an async runtime in a new thread.
12+ Create a function that starts an async runtime in a new thread.
1313
14- By accepting a component id and an emitter it is possible to send messages into
14+ Using a component id and an emitter it is possible to send messages into
1515the Anathema runtime.
1616
17+ In this example we assume there is a component that accepts a ` usize ` as its
18+ ` Message ` type.
19+
1720``` rust,ignore
18- pub fn run_async(emitter: Emitter, component: ComponentId<MessageType >) {
21+ pub fn run_async(emitter: Emitter, component: ComponentId<usize >) {
1922 thread::spawn(move || {
2023 tokio::runtime::Builder::new_multi_thread()
2124 .enable_all()
2225 .build()
2326 .unwrap()
2427 .block_on(async move {
2528 // async code here
29+ emitter.emit_async(component, 123).await;
2630 });
2731 });
2832}
You can’t perform that action at this time.
0 commit comments