leptos_struct_table/
reload_controller.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use leptos::prelude::*;

/// You can pass this to a [`TableContent`] component's `reload_controller` prop to trigger a reload.
///
/// See the [paginated_rest_datasource example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/paginated_rest_datasource/src/main.rs)
/// for how to use.
#[derive(Copy, Clone)]
pub struct ReloadController(Trigger);

impl Default for ReloadController {
    fn default() -> Self {
        Self(Trigger::new())
    }
}

impl ReloadController {
    pub fn reload(&self) {
        self.0.notify();
    }

    pub fn track(&self) {
        self.0.track();
    }
}