pub trait Notification: NotificationPrivate { }
Expand description

A notification that can be used to notify an Event.

This type is used by the [Event::notify()] function to determine how many listeners to wake up, whether or not to subtract additional listeners, and other properties. The actual internal data is hidden in a private trait and is intentionally not exposed. This means that users cannot manually implement the Notification trait. However, it also means that changing the underlying trait is not a semver breaking change.

Users can create types that implement notifications using the combinators on the IntoNotification type. Typical construction of a Notification starts with a numeric literal (like 3usize) and then optionally adding combinators.

Example

use event_listener::{Event, prelude::*};

fn notify(ev: &Event, notify: impl Notification<Tag = ()>) {
    ev.notify(notify);
}

notify(&Event::new(), 1.additional());

Implementors§

source§

impl<N: NotificationPrivate + ?Sized> Notification for N