mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-23 14:29:22 -05:00
1e4832a6d0
* demo: refactor docs * demo: refactor docs * demo: refactor docs * demo: refactor docs
34 lines
1.1 KiB
Markdown
34 lines
1.1 KiB
Markdown
# Loading Bar
|
|
|
|
<Alert variant=AlertVariant::Warning title="Prerequisite">
|
|
"If you want to use loading bar, you need to wrap the component where you call related methods inside LoadingBarProvider and use use_loading_bar to get the API."
|
|
</Alert>
|
|
|
|
```rust demo
|
|
let loading_bar = use_loading_bar();
|
|
let start = Callback::new(move |_| {
|
|
loading_bar.start();
|
|
});
|
|
let finish = Callback::new(move |_| {
|
|
loading_bar.finish();
|
|
});
|
|
let error = Callback::new(move |_| {
|
|
loading_bar.error();
|
|
});
|
|
|
|
view! {
|
|
<Space>
|
|
<Button on_click=start>"start"</Button>
|
|
<Button on_click=finish>"finish"</Button>
|
|
<Button on_click=error>"error"</Button>
|
|
</Space>
|
|
}
|
|
```
|
|
|
|
### LoadingBarProvider Injection Methods
|
|
|
|
| Name | Type | Description |
|
|
| ------ | ----------- | ------------------------------------------------------------ |
|
|
| start | `fn(&self)` | Callback function for loading bar to start loading. |
|
|
| finish | `fn(&self)` | The callback function when the loading bar finishes loading. |
|
|
| error | `fn(&self)` | Callback function for loading bar error. |
|