Save and restore the list
A task list shouldn't lose your work when the window closes. Persistence in mirui is declarative: mark durable fields with #[persist], install PersistencePlugin, and the model restores its snapshot as soon as it is registered.
1. Minimal demo: #[persist] and simulated relaunch
Here is a minimal persistent counter: SavedCount opts into #[model(persistence(key = "..."))] and marks value with #[persist].
Tap + 1 (Autosaves) a few times, wait 0.2 seconds, and click Relaunch ↻ at the bottom-right of the workspace—it destroys the running App instance and mounts a brand-new one from storage:
2. In the task list: autosave and startup restoration
Now we annotate Task and Tasks in model.rs and install PersistencePlugin before app.add_model(...) in lib.rs:
`lib.rs` installs `PersistencePlugin::new(storage).autosave(500)` **before** calling `app.add_model(Tasks::default()).finish()`.
app.add_plugin(PersistencePlugin::new(storage).autosave(500));Plugin order contract enforcedWhat changed in this step
- Install the plugin before registering models:
app.add_model(Tasks::default()).finish()queriesPersistencePluginimmediately during registration, so the very first composed frame already reflects the restored data. - Persist domain data, not transient UI state: Notice
filteronTasksis marked#[observe]but not#[persist]. Active filter tabs and in-flight animations reset cleanly on launch while tasks and completion states endure.
Run on your machine
cargo run -p mirui-first-app --features desktop --example desktop -- 6