thaw/demo_markdown/docs/loading_bar/mod.md

40 lines
1.3 KiB
Markdown
Raw Normal View History

# Loading Bar
2024-06-27 22:28:10 +08:00
<MessageBar layout=MessageBarLayout::Multiline intent=MessageBarIntent::Warning>
<MessageBarBody>
<h3 style="margin: 0">"Prerequisite"</h3>
<p>
"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."
</p>
</MessageBarBody>
</MessageBar>
```rust demo
2024-07-09 15:04:20 +08:00
let loading_bar = LoadingBarInjection::expect_use();
let start = move |_| {
loading_bar.start();
2024-07-09 15:04:20 +08:00
};
let finish = move |_| {
loading_bar.finish();
2024-07-09 15:04:20 +08:00
};
let error = move |_| {
loading_bar.error();
2024-07-09 15:04:20 +08:00
};
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. |