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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright 2025 Umberto Gotti <umberto.gotti@umbertogotti.dev>
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
//! Extension trait providing the `combine_latest` operator for `Timestamped` streams.
//!
//! This trait enables combining multiple streams where each emission waits for
//! at least one value from all streams, then emits the combination of the latest
//! values from each stream.
//!
//! # Behavior
//!
//! - Waits until all streams have emitted at least one value
//! - After initialization, emits whenever any stream produces a value
//! - Maintains temporal ordering using the `Ordered` trait
//! - Allows filtering emissions based on the combined state
//!
//! # Example
//!
//! ```rust
//! use fluxion_stream::CombineLatestExt;
//! use fluxion_test_utils::{Sequenced, helpers::unwrap_stream, unwrap_value, test_channel};
//! use fluxion_core::Timestamped as TimestampedTrait;
//!
//! # async fn example() {
//! // Create channels
//! let (tx1, stream1) = test_channel::<Sequenced<i32>>();
//! let (tx2, stream2) = test_channel::<Sequenced<i32>>();
//!
//! // Combine streams
//! let mut combined = stream1.combine_latest(
//! vec![stream2],
//! |state| state.values().len() == 2
//! );
//!
//! // Send values
//! tx1.unbounded_send((1, 1).into()).unwrap();
//! tx2.unbounded_send((2, 2).into()).unwrap();
//!
//! // Assert
//! let result = unwrap_value(Some(unwrap_stream(&mut combined, 500).await));
//! let values = result.values();
//! assert_eq!(values.len(), 2);
//! assert_eq!(values[0], 1);
//! assert_eq!(values[1], 2);
//! # }
//! ```
pub use CombineLatestExt;
pub use CombineLatestExt;