pub struct ChannelSignal<T, E> { /* private fields */ }Expand description
A reactive signal for channels that produce multiple values with error handling.
ChannelSignal provides a way to reactively consume values from channels and automatically
update UI when new values arrive or errors occur. It manages the channel lifecycle and provides
access to both the current value and any errors.
§Examples
ⓘ
// Simple case: std::thread executor, returns ChannelSignal<Option<T>, E>
let channel_signal = ChannelSignal::new(receiver);
// With initial value
let channel_signal = ChannelSignal::with_initial(receiver, initial_value);
// Full customization
let channel_signal = ChannelSignal::custom(receiver)
.event_loop()
.initial(initial_value)
.build();Implementations§
Source§impl<T: Send + 'static, E: Send + 'static> ChannelSignal<T, E>
impl<T: Send + 'static, E: Send + 'static> ChannelSignal<T, E>
Sourcepub fn new<R>(receiver: R) -> ChannelSignal<Option<T>, E>where
R: BlockingReceiver<Item = T, Error = E> + Send + 'static,
pub fn new<R>(receiver: R) -> ChannelSignal<Option<T>, E>where
R: BlockingReceiver<Item = T, Error = E> + Send + 'static,
Creates a new reactive channel signal with sensible defaults.
- Executor: Std::thread for blocking receivers, event loop for pollable receivers
- Initial value: None (returns
ChannelSignal<Option<U>, E>)
§Parameters
receiver- The channel receiver to consume.
§Examples
ⓘ
let channel_signal = ChannelSignal::new(receiver);pub fn new_poll<R>(receiver: R) -> ChannelSignal<Option<T>, E>where
R: PollableReceiver<Item = T, Error = E> + Send + 'static,
Sourcepub fn with_initial<R>(receiver: R, initial: T) -> Selfwhere
R: BlockingReceiver<Item = T, Error = E> + Send + 'static,
pub fn with_initial<R>(receiver: R, initial: T) -> Selfwhere
R: BlockingReceiver<Item = T, Error = E> + Send + 'static,
Creates a new reactive channel 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: Std::thread for blocking receivers, event loop for pollable receivers
§Parameters
receiver- The channel receiver to consume.initial- The initial value for the signal before any message arrives.
§Examples
ⓘ
let channel_signal = ChannelSignal::with_initial(receiver, initial_value);Sourcepub fn custom<R>(
receiver: R,
) -> ChannelSignalBuilder<R, T, E, StdThreadExecutor, NoInitial>
pub fn custom<R>( receiver: R, ) -> ChannelSignalBuilder<R, T, E, StdThreadExecutor, NoInitial>
Creates a channel signal builder for full customization.
Use this when you need to customize:
- The executor (event loop, tokio, std::thread, etc.)
- Initial value
§Examples
ⓘ
// Event loop executor with initial value
let channel_signal = ChannelSignal::custom(receiver)
.event_loop()
.initial(initial_value)
.build();pub fn error(&self) -> ReadSignal<Option<E>>
Trait Implementations§
Source§impl<T, E> Clone for ChannelSignal<T, E>
impl<T, E> Clone for ChannelSignal<T, E>
Source§impl<T: Send + 'static> From<Receiver<T>> for ChannelSignal<Option<T>, RecvError>
This implementation will be removed in the future
impl<T: Send + 'static> From<Receiver<T>> for ChannelSignal<Option<T>, RecvError>
This implementation will be removed in the future
Source§impl<T, E> SignalGet<T> for ChannelSignal<T, E>where
T: Clone,
impl<T, E> SignalGet<T> for ChannelSignal<T, E>where
T: Clone,
Source§impl<T, E> SignalRead<T> for ChannelSignal<T, E>
impl<T, E> SignalRead<T> for ChannelSignal<T, E>
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, E> SignalTrack<T> for ChannelSignal<T, E>
impl<T, E> SignalTrack<T> for ChannelSignal<T, E>
Source§impl<T, E> SignalWith<T> for ChannelSignal<T, E>
impl<T, E> SignalWith<T> for ChannelSignal<T, E>
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, E> Copy for ChannelSignal<T, E>
Auto Trait Implementations§
impl<T, E> Freeze for ChannelSignal<T, E>
impl<T, E> RefUnwindSafe for ChannelSignal<T, E>where
T: RefUnwindSafe,
E: RefUnwindSafe,
impl<T, E> !Send for ChannelSignal<T, E>
impl<T, E> !Sync for ChannelSignal<T, E>
impl<T, E> Unpin for ChannelSignal<T, E>
impl<T, E> UnwindSafe for ChannelSignal<T, E>where
T: UnwindSafe,
E: 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