pub struct StreamSignal<T> { /* private fields */ }Expand description
A reactive signal for streams that produce multiple values.
StreamSignal provides a way to reactively consume values from async streams and automatically
update UI when new values arrive. It manages the stream lifecycle and provides access to both
the current value and completion state.
§Examples
ⓘ
// Simple case: event loop executor, returns StreamSignal<Option<T>>
let stream_signal = StreamSignal::new(my_stream);
// With initial value
let stream_signal = StreamSignal::with_initial(my_stream, initial_value);
// Full customization
let stream_signal = StreamSignal::custom(my_stream)
.tokio_spawn()
.initial(initial_value)
.build();Implementations§
Source§impl<T: 'static> StreamSignal<T>
impl<T: 'static> StreamSignal<T>
Sourcepub fn new<S>(stream: S) -> StreamSignal<Option<T>>where
S: Stream<Item = T> + 'static,
T: 'static,
pub fn new<S>(stream: S) -> StreamSignal<Option<T>>where
S: Stream<Item = T> + 'static,
T: 'static,
Sourcepub fn with_initial<S>(stream: S, initial: T) -> Selfwhere
S: Stream<Item = T> + 'static,
pub fn with_initial<S>(stream: S, initial: T) -> Selfwhere
S: Stream<Item = T> + 'static,
Creates a new reactive stream signal with an initial value.
Uses the same defaults as new() but allows you to specify an initial value
so the signal is never None.
- Executor: Main event loop (stream does not need to be
Send)
§Parameters
stream- The async stream to consume.initial- The initial value for the signal before any stream item arrives.
§Examples
ⓘ
let stream_signal = StreamSignal::with_initial(my_stream, initial_value);Sourcepub fn custom<S>(
stream: S,
) -> StreamSignalBuilder<S, T, EventLoopExecutor, NoInitial>where
S: Stream<Item = T> + 'static,
T: 'static,
pub fn custom<S>(
stream: S,
) -> StreamSignalBuilder<S, T, EventLoopExecutor, NoInitial>where
S: Stream<Item = T> + 'static,
T: 'static,
pub fn is_finished(&self) -> bool
Trait Implementations§
Source§impl<T> Clone for StreamSignal<T>
impl<T> Clone for StreamSignal<T>
Source§impl<T: 'static, S> From<S> for StreamSignal<Option<T>>where
S: Stream<Item = T> + 'static,
This implementation will be removed in the future
impl<T: 'static, S> From<S> for StreamSignal<Option<T>>where
S: Stream<Item = T> + 'static,
This implementation will be removed in the future
Source§impl<T> SignalGet<T> for StreamSignal<T>where
T: Clone,
impl<T> SignalGet<T> for StreamSignal<T>where
T: Clone,
Source§impl<T> SignalRead<T> for StreamSignal<T>
impl<T> SignalRead<T> for StreamSignal<T>
Source§fn id(&self) -> ReactiveId
fn id(&self) -> ReactiveId
get the Signal Id
Source§fn try_read(&self) -> Option<ReadRef<'_, T>>where
T: 'static,
fn try_read(&self) -> Option<ReadRef<'_, T>>where
T: 'static,
If the signal isn’t disposed,
reads the data stored in the Signal and subscribes to the current running effect.
Source§fn try_read_untracked(&self) -> Option<ReadRef<'_, T>>where
T: 'static,
fn try_read_untracked(&self) -> Option<ReadRef<'_, T>>where
T: 'static,
If the signal isn’t disposed,
reads the data stored in the Signal without subscribing.
Source§fn read(&self) -> ReadRef<'_, T>where
T: 'static,
fn read(&self) -> ReadRef<'_, T>where
T: 'static,
Reads the data stored in the Signal, subscribing the current running effect.
Source§fn read_untracked(&self) -> ReadRef<'_, T>where
T: 'static,
fn read_untracked(&self) -> ReadRef<'_, T>where
T: 'static,
Reads the data stored in the Signal without subscribing.
Source§impl<T> SignalTrack<T> for StreamSignal<T>
impl<T> SignalTrack<T> for StreamSignal<T>
Source§impl<T> SignalWith<T> for StreamSignal<T>
impl<T> SignalWith<T> for StreamSignal<T>
Source§fn id(&self) -> ReactiveId
fn id(&self) -> ReactiveId
get the Signal Id
fn with<O>(&self, f: impl FnOnce(&T) -> O) -> Owhere
T: 'static,
fn with_untracked<O>(&self, f: impl FnOnce(&T) -> O) -> Owhere
T: 'static,
fn try_with<O>(&self, f: impl FnOnce(Option<&T>) -> O) -> Owhere
T: 'static,
fn try_with_untracked<O>(&self, f: impl FnOnce(Option<&T>) -> O) -> Owhere
T: 'static,
impl<T> Copy for StreamSignal<T>
Auto Trait Implementations§
impl<T> Freeze for StreamSignal<T>
impl<T> RefUnwindSafe for StreamSignal<T>where
T: RefUnwindSafe,
impl<T> !Send for StreamSignal<T>
impl<T> !Sync for StreamSignal<T>
impl<T> Unpin for StreamSignal<T>where
T: Unpin,
impl<T> UnwindSafe for StreamSignal<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more