A simple observable (IObservable<T>
) that when its value is updated (value changes), its observers are notified.
Will post current value (if initialized) when subscribing. Synchronized to ensure ordering.
System.Reactive
is included and can be used to extend its behavior.
using Open.Observable;
var value = new ObservableValue<int>(1 /* optional initial value */);
or
var value = ObservableValue.Create(1); // type inferred
value.Subscribe(v => { /* do something with the value */ });
var changed = value.Post(2);