feat(store)!: fully rework and add auto save (#1550)

* Add auto save to store plugin

* Put jsdoc at constructor instead of class level

* Clippy

* Use enum instead of bool

* Some(AutoSaveMessage::Cancel) | None

* from_millis

* u64

* Add change file

* Rename to emit_on_change

* should use Duration in `with_store`

* Add breaking change notice to change file

* Emit change event for inserts by reset

* Update readme example

* Update example

* Remove extra line

* Make description clear it only works with managed

* Fix links in docstring

* Fix doc string closing

* get_mut

* Proof of concept

* fmt

* Load store on create

* cargo fmt

* Fix merge conflits

* Format

* small cleanup

* update docs, use `impl Into<JsonValue>`

* fix doctests, further simplification of api

* add store options

---------

Co-authored-by: Tillmann <28728469+tweidinger@users.noreply.github.com>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
Tony
2024-10-01 15:10:40 -03:00
committed by GitHub
co-authored by Tillmann Lucas Nogueira
parent 44273b9889
commit f12d35609a
16 changed files with 604 additions and 364 deletions
+3 -5
View File
@@ -149,12 +149,10 @@ As you may have noticed, the `Store` crated above isn't accessible to the fronte
```rust
use tauri::Wry;
use tauri_plugin_store::with_store;
use tauri_plugin_store::StoreExt;
let stores = app.state::<StoreCollection<Wry>>();
let path = PathBuf::from("app_data.bin");
with_store(app_handle, stores, path, |store| store.insert("a".to_string(), json!("b")))
let store = app.store_builder("app_data.bin").build();
store.insert("key", "value");
```
## Contributing