windows-reactor
Windows Reactor is a declarative WinUI 3 library for Rust. A Component owns state, receives
parent-owned input, handles typed messages, and returns a View. Reactor reconciles each new view
with the native UI tree and applies the required WinUI changes.
Add Reactor:
[dependencies]
windows-reactor = "0.100"
This counter shows the Component/View model:
use windows_reactor::*;
struct Counter {
count: u32,
}
impl Component for Counter {
type Input = ();
type Message = ();
fn create(_input: &(), _context: &ComponentContext<Self>) -> Self {
Self { count: 0 }
}
fn update(&mut self, _message: (), _context: &ComponentContext<Self>) {
self.count += 1;
}
fn view(&self, _input: &(), context: &mut ViewContext<Self>) -> View {
StackPanel::new().spacing(8.0).children((
TextBlock::new().text(format!("Count: {}", self.count)),
Button::new()
.on_click(context.forward())
.content("Increment"),
))
}
}
fn main() {
App::run_component::<Counter>(()).unwrap();
}