Struct relm4::component::worker::WorkerHandle
source · pub struct WorkerHandle<W: Component> { /* private fields */ }
Expand description
Handle to a worker task in the background
Implementations§
source§impl<W: Component> WorkerHandle<W>
impl<W: Component> WorkerHandle<W>
sourcepub fn connect_receiver<F: FnMut(&mut Sender<W::Input>, W::Output) + 'static>(
self,
func: F
) -> WorkerController<W>
pub fn connect_receiver<F: FnMut(&mut Sender<W::Input>, W::Output) + 'static>( self, func: F ) -> WorkerController<W>
Given a mutable closure, captures the receiver for handling.
sourcepub fn forward<X: 'static, F: Fn(W::Output) -> X + 'static>(
self,
sender: &Sender<X>,
transform: F
) -> WorkerController<W>
pub fn forward<X: 'static, F: Fn(W::Output) -> X + 'static>( self, sender: &Sender<X>, transform: F ) -> WorkerController<W>
Forwards output events to the designated sender.
Examples found in repository?
examples/worker.rs (line 97)
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
fn init(
_: Self::Init,
root: Self::Root,
sender: ComponentSender<Self>,
) -> ComponentParts<Self> {
let model = App {
counter: 0,
worker: AsyncHandler::builder()
.detach_worker(())
.forward(sender.input_sender(), identity),
};
let widgets = view_output!();
ComponentParts { model, widgets }
}
sourcepub fn detach(self) -> WorkerController<W>
pub fn detach(self) -> WorkerController<W>
Ignore outputs from the component and finish the builder.
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for WorkerHandle<W>
impl<W> !RefUnwindSafe for WorkerHandle<W>
impl<W> Send for WorkerHandle<W>
impl<W> Sync for WorkerHandle<W>
impl<W> Unpin for WorkerHandle<W>
impl<W> !UnwindSafe for WorkerHandle<W>
Blanket Implementations§
source§impl<C> AsyncPosition<()> for C
impl<C> AsyncPosition<()> for C
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