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
use Stream;
use crate::;
/// Subscribes to theme changes as an async [`Stream`].
///
/// This is an adapter over [`crate::subscribe`]. On most platforms it drives the
/// underlying blocking [`crate::Watcher`] on a background thread and forwards each
/// [`Mode`] into the returned stream. On `wasm32` (which has no threads here), the
/// browser's `MediaQueryList` `change` event is forwarded directly instead.
///
/// # Example
///
/// ``` no_run
/// use dark_light::{ Error, Mode };
/// use futures_util::StreamExt;
///
/// fn main() -> Result<(), Error> {
/// futures_executor::block_on(async {
/// let mut stream = dark_light::stream()?;
/// while let Some(mode) = stream.next().await {
/// match mode {
/// Mode::Dark => {},
/// Mode::Light => {},
/// Mode::Unspecified => {},
/// }
/// }
/// Ok(())
/// })
/// }
/// ```