Skip to content

Plugin for macro-, mini-quad (quads) to save data in simple local storage using Web Storage API in WASM and local file on a native platforms.

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
Unknown
LICENSE-MIT
Notifications You must be signed in to change notification settings

optozorax/quad-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quad-storage

Docs Crates.io version

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.

Web demo.

Code example

let storage = &mut quad_storage::STORAGE.lock().unwrap();
storage.set("test", "value");
let value = storage.get("test").unwrap();
dbg!(value);

Usage

Add this to your Cargo.toml dependencies:

quad-storage = "0.1.0"

Usage in WASM

Add file quad-storage/js/quad-storage.js to your project.

Add file sapp-jsutils/js/sapp_jsutils.js file to your project.

Add this lines after loading of gl.js and before loading of your wasm in your index.html:

<script src="sapp_jsutils.js"></script>
<script src="quad-storage.js"></script>

Done! Now you can use this crate.

About

Plugin for macro-, mini-quad (quads) to save data in simple local storage using Web Storage API in WASM and local file on a native platforms.

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
Unknown
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published