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
// 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 `with_latest_from` operator for timestamped streams.
//!
//! This operator combines a primary stream with a secondary stream, emitting only
//! when the primary stream emits, using the latest value from the secondary stream.
//!
//! # Behavior
//!
//! - Emissions are triggered **only** by the primary stream (self)
//! - Secondary stream updates are stored but don't trigger emissions
//! - Waits until both streams have emitted at least once
//! - Preserves temporal ordering from the primary stream
//!
//! # Examples
//!
//! ```rust
//! use fluxion_stream::WithLatestFromExt;
//! use fluxion_test_utils::{Sequenced, helpers::unwrap_stream, unwrap_value, test_channel};
//! use fluxion_core::Timestamped as TimestampedTrait;
//!
//! # async fn example() {
//! // Create channels
//! let (tx_primary, primary) = test_channel::<Sequenced<i32>>();
//! let (tx_secondary, secondary) = test_channel::<Sequenced<i32>>();
//!
//! // Combine streams
//! let mut combined = primary.with_latest_from(
//! secondary,
//! |state| state.clone()
//! );
//!
//! // Send values
//! tx_secondary.unbounded_send((10, 1).into()).unwrap();
//! tx_primary.unbounded_send((1, 2).into()).unwrap();
//!
//! // Assert
//! let result = unwrap_value(Some(unwrap_stream(&mut combined, 500).await));
//! let values = result.values();
//! assert_eq!(values[0] + values[1], 11);
//! # }
//! ```
pub use WithLatestFromExt;
pub use WithLatestFromExt;