Stores
Stores make it easy to persist class/object properties to a store with one line of code. You can move between store types in that same line of code. We provide stores for iOS, Android, Windows, & WebAssembly.
- GitHub Repository
- Nuget Packages
Features
Section titled “Features”- Key/value store with support for
- Android/iOS/Windows - Preferences & Secure Storage
- Web - Local Storage & Session Storage
- In Memory
- Object binder binds INotifyPropertyChanged against a key/value store to persist object changes across sessions
- Simply implement IKeyValueStore to create your own store
-
Add the following using directive:
// during your app startup - use your service collectionbuilder.Services.AddPersistentService<MyNotifyPropertyChangedObject>("secure"); // optional: default to `settings` -
Inject the MyNotifyPropertyChangedObject into your view model or service. Set properties and they will be persisted automatically.
public class MyViewModel{public MyViewModel(MyNotifyPropertyChangedObject myObject)=> this.MyObject = myObject;public MyNotifyPropertyChangedObject MyObject { get; }public void SomeMethod(){MyClass.MyProperty = "Hello World"; // this will be persisted automatically}} -
To bypass reflection and make binding super fast - use Shiny Reflector to remove the need for reflection. It is already built into the Shiny.Extensions.Stores package, so you can use it directly. Just mark
[Reflector]
on your class and make your class partial.
Available Stores Per Platform
Section titled “Available Stores Per Platform”Platform | Store Alias | Description |
---|---|---|
Android | settings | Preferences store |
Android | secure | Secure Storage |
iOS | settings | Preferences store |
iOS | secure | Secure Storage |
WebAssembly | settings | Local Storage |
WebAssembly | session | Session Storage |
Windows | settings | Preferences store |
Windows | secure | Secure Storage |
All | Memory | In Memory store - great for testing |