dioxus/docs/main-concepts/04-hooks.md

17 lines
428 B
Markdown
Raw Normal View History

2021-01-14 07:56:41 +00:00
```rust
2021-06-26 01:15:33 +00:00
fn Example(cx: &mut Context<()>) -> VNode {
let service = use_combubulator(cx);
2021-01-14 07:56:41 +00:00
let Status { name, pending, count } = service.info();
2021-06-26 01:15:33 +00:00
html! {
<div>
2021-01-14 07:56:41 +00:00
<p> "Hello, {name}!" </p>
<p> "Status: {pending}!" </p>
<p> "Count {count}!" </p>
2021-06-26 01:15:33 +00:00
<button onclick=|_| service.update()>
2021-01-14 07:56:41 +00:00
"Refresh services"
</button>
2021-06-26 01:15:33 +00:00
</div>
2021-01-14 07:56:41 +00:00
}
}
```