spawn_local

Function spawn_local 

Source
pub fn spawn_local<F, Out>(func: F) -> JoinHandle<Out>
where F: Future<Output = Out> + 'static, Out: 'static,
Expand description

Spawns a thread-local future on GLib’s executor, for non-Send futures.

Examples found in repository?
relm4/examples/typed_list_view_async.rs (lines 93-99)
84    fn bind(&mut self, widgets: &mut Self::Widgets, _root: &mut Self::Root) {
85        println!("Unbind {}", self.value);
86        let Widgets {
87            label,
88            label2,
89            button,
90        } = widgets;
91
92        let future_binding = self.binding.clone();
93        self.handle = Some(relm4::spawn_local(async move {
94            loop {
95                tokio::time::sleep(Duration::from_secs(1)).await;
96                let mut guard = future_binding.guard();
97                *guard = guard.wrapping_add(1);
98            }
99        }));
100
101        label.set_label(&format!("Value: {} ", self.value));
102        label2.add_write_only_binding(&self.binding, "label");
103        button.set_active(self.value.is_multiple_of(2));
104    }