This is the crate to save data in persistent local storage in miniquad/macroquad environment. In WASM the data persists even if tab or browser are closed. To achieve that Web Storage API is used. To save data on native platforms, data is just saved to the local file named local.data
.
rust
let storage = &mut quad_storage::STORAGE.lock().unwrap();
storage.set("test", "value");
let value = storage.get("test").unwrap();
dbg!(value);
Add this to your Cargo.toml
dependencies:
text
quad-storage = "0.1.0"
Add file quad-storage/js/quad-storage.js
to your project.
Add file sapp-jsutils/js/sapp_jsutils.js
file to your project. (version 0.1.5
is compatible with current crate)
Add this lines after loading of gl.js
and before loading of your wasm in your index.html
:
```html
``` Done! Now you can use this crate.