1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Events: typed values that listeners react to, with injected services.
//!
//! When a customer places an order, the order code can dispatch one event, and listeners send the
//! receipt and write the audit log without the order code knowing about either. This module
//! provides the [`Event`](derive@Event) derive, the [`#[listener]`](macro@listener) attribute, the
//! [`Dispatcher`] that holds listeners, and the [`dispatch`] and [`dispatch_background`]
//! functions. To learn more, check out the
//! [events guide](https://github.com/laravel/rust-framework/blob/0.x/docs/events.md).
//!
//! Applications discover the `#[listener]` functions in the `app` crate automatically. Register
//! other listeners with
//! [`ApplicationBuilder::with_events`](crate::foundation::ApplicationBuilder::with_events).
//! Dispatching an event awaits its listeners in registration order and returns the first
//! failure. Inside a database transaction, the listeners wait for the transaction to commit,
//! unless the event is marked [`#[event(at_dispatch)]`](derive@Event) or the listener is
//! registered with [`Dispatcher::listen_at_dispatch`].
//!
//! ```
//! use laravel::Application;
//! use laravel::event::Event;
//!
//! #[derive(Event)]
//! struct OrderPlaced {
//! id: u64,
//! }
//!
//! async fn send_receipt(event: Event<OrderPlaced>) {
//! assert_eq!(event.id, 42);
//! }
//!
//! let app = Application::configure()
//! .replace_env(laravel::config::Env::default())
//! .with_events(|events, _| {
//! events.listen(send_receipt);
//! })
//! .create();
//!
//! # laravel::testing::__run(async {
//! app.scope(async || OrderPlaced { id: 42 }.dispatch().await)
//! .await
//! .unwrap();
//! # });
//! ```
pub use *;
pub use ;
pub use ;