Can you bake your own class for this? I've written a little sudo code for a demo, if you need a more concrete example I can provide one at a later time.
InMemoryOptionsMonitor {
T _value;
ctor(T value) {
_value = value;
}
event EventHandler<T> OnChange;
void Replace(T newValue)
{
_value = newValue;
OnChange.Invoke(this, newValue);
}
## OR
void Update(Action<T> update)
{
update(_value);
OnChange.Invoke(this, _value);
}
T Current() => _value;
}
I would preferable use T to be a readonly struct/record, then consumers can only update the value in the Options monitor through the replace method