Show / Hide Table of Contents

State

One important variation of Observable<T> is State<T>, which is a mutable observable, meaning you can also set the value:

interface State<T> : Observable<T>
{
    T Value { get; set; }
}

Like most of observables, State<T> can be created by a static function in the Observable helper class:

static class Observable
{
    static State<T> State<T>(T initialValue);
}

Example

var o = Observable.State(42);
Console.WriteLine(o.Value); // 42
o.Value = 24;
Console.WriteLine(o.Value); // 24
In This Article
Back to top Generated by DocFX