Strongly-typed, compile-time mediator.
See the documentation on docs.rs
```rust use noon::mediator::{Mediate, MediatorBuilder};
// Create message types struct NewUserRequest { id: i32 }; struct NewUserResponse { total_users: u32 }; struct SendUserEmail { id: i32, msg: String }; struct NewUserLogin { id: i32 };
async fn foo() {
// Create a mediator
let mediator = MediatorBuilder::new()
.addhandler(|x: NewUserRequest| {
// get total users
NewUserResponse { totalusers: 13 }
})
.addasynchandler(|x: SendUserEmail| async move {
// send email
true
})
.listenfor::
mediator.notify(&NewUserLogin { id: 5 });
let response = mediator.handle(NewUserRequest { id: 5 });
println!("There are now {} users in the system", response.total_users);
}
let mediator = MediatorBuilder::new() .build(); ```
noon is dual licensed under the terms of the MIT or Apache-2.0 licenses. You may choose whichever you prefer.