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 fn init(
89 _: Self::Init,
90 root: Self::Root,
91 sender: ComponentSender<Self>,
92 ) -> ComponentParts<Self> {
93 let model = App {
94 counter: 0,
95 worker: AsyncHandler::builder()
96 .detach_worker(())
97 .forward(sender.input_sender(), identity),
98 };
99
100 let widgets = view_output!();
101
102 ComponentParts { model, widgets }
103 }
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