Skip to content

SettingsStorage class

Defined in

Namespace: Akavache.Settings.Core Assembly: Akavache.Settings.dll Full name: Akavache.Settings.Core.SettingsStorage Modifiers: public abstract

Summary

View source

Provides a base class for implementing observable application settings storage using Akavache. Each property is exposed as a live IObservable backed by a SettingsStream — subscribers see the current value immediately, are updated on every write, and never block the calling thread. Persistence goes through the underlying IBlobCache asynchronously.

Applies to

net10.0, net10.0-tvos26.0, net10.0-maccatalyst26.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net10.0-android36.0, net10.0-ios26.0, net10.0-windows10.0.19041, net10.0-macos26.0, net9.0, net9.0-windows10.0.19041, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-windows10.0.19041, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net481, net462

Class hierarchy
classDiagram
class SettingsStorage
class ISettingsStorage {
    <>
}
ISettingsStorage <|.. SettingsStorage
class INotifyPropertyChanged {
    <>
}
INotifyPropertyChanged <|.. SettingsStorage
class IDisposable {
    <>
}
IDisposable <|.. SettingsStorage

Implements: ISettingsStorage, INotifyPropertyChanged, IDisposable

Remarks

This is a deliberate break from the earlier GetOrCreate<T>/SetOrCreate<T> sync getter pattern. That model called .Wait() on the underlying blob cache's observable chain — a synchronous bridge that deadlocked (and occasionally crashed natively) against async backends like the worker-thread sqlite queue. The observable shape fits Akavache's core API and eliminates the whole class of .Wait() hazards from settings code.

Typical derived class:

public sealed class MySettings : SettingsBase
 {
 public MySettings() : base(nameof(MySettings)) { }
 
 public IObservable<bool> Enabled => GetOrCreateObservable(true);
 
 public IObservable<Unit> SetEnabled(bool value) =>
 SetObservable(value, nameof(Enabled));
 }

Callers subscribe to Enabled to receive the current value + any future updates, or call await settings.Enabled.FirstAsync() for a one-shot read.

Constructors

NameSummary
.ctorInitializes a new instance of the [SettingsStorage](# class.

Methods

NameSummary
InitializePre-warms every settings property by triggering its getter (which lazily creates the backing SettingsStream) and waiting for each stream's cold load from disk to complete. Calling this at...
DisposePerforms application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
GetOrCreateObservableReturns the live observable stream for a settings property, creating it on first access. The returned observable emits the current value on subscribe (starting with defaultValue until the cold...
CreatePropertyCreates a property facade backed by the live observable stream for propertyName. The returned [SettingsPropertyHelper](# exposes a sync Value...
SetObservableUpdates the live stream for a settings property and enqueues a persistent write. Also raises [PropertyChanged](# for non-Rx consumers. If the...
OnPropertyChangedRaises the [PropertyChanged](# event for the specified property name.

Events

NameSummary
PropertyChangedOccurs when a property value changes. Raised by [SetObservable](# after updating the underlying stream so plain...

Derived types

Inherited members