Skip to content

Commit

Permalink
chore: update example for use with 0.6.0 (#228)
Browse files Browse the repository at this point in the history
refs #222
  • Loading branch information
defigli authored Nov 16, 2024
1 parent 3714ce8 commit c77b3af
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ A tiny, fast, and safe actor framework. It is modelled around Actix (copyright a
result on my development machine with an AMD Ryzen 3 3200G.

## Example

This is an example to use `xtra` with `tokio`. To compile this example it is needed to add the features `tokio` and `macros` in `Cargo.toml`.

```toml
[dependencies]
xtra = { version = "0.6.0", features = ["tokio", "macros"] }
```

```rust
use xtra::prelude::*;

Expand All @@ -40,7 +48,7 @@ impl Handler<Print> for Printer {

#[tokio::main]
async fn main() {
let addr = xtra::spawn_tokio(Printer::default(), None);
let addr = xtra::spawn_tokio(Printer::default(), Mailbox::unbounded());
loop {
addr.send(Print("hello".to_string()))
.await
Expand All @@ -55,7 +63,7 @@ For a longer example, check out [Vertex](https://github.com/Restioson/vertex/tre
## Okay, sounds great! How do I use it?

Check out the [docs](https://docs.rs/xtra) and the [examples](https://github.com/Restioson/xtra/tree/master/xtra/examples) to get started!
Enabling the `tokio`, `async_std`, `smol`, or `wasm_bindgen` features is recommended in order to enable some convenience methods (such as `xtra::spawn_tokio`).
Enabling the `tokio`, `macros`, `async_std`, `smol`, or `wasm_bindgen` features is recommended in order to enable some convenience methods (such as `xtra::spawn_tokio`).
Which you enable will depend on which executor you want to use (check out their docs to learn more about each).
If you have any questions, feel free to [open an issue](https://github.com/Restioson/xtra/issues/new) or message me on the [Rust discord](https://bit.ly/rust-community).

Expand Down

0 comments on commit c77b3af

Please sign in to comment.