Skip to content

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.

  • 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
  1. Install the NuGet package

  2. Add the following using directive:

    // during your app startup - use your service collection
    builder.Services.AddPersistentService<MyNotifyPropertyChangedObject>("secure"); // optional: default to `settings`
  3. 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
    }
    }
  4. 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.

PlatformStore AliasDescription
AndroidsettingsPreferences store
AndroidsecureSecure Storage
iOSsettingsPreferences store
iOSsecureSecure Storage
WebAssemblysettingsLocal Storage
WebAssemblysessionSession Storage
WindowssettingsPreferences store
WindowssecureSecure Storage
AllMemoryIn Memory store - great for testing