public class ObserverSubscribe<T> : Subscribe<T>
{
private IObserver<T> observer;
public ObserverSubscribe(IObserver<T> observer)
{
this.observer = observer;
}
public override Action<T> OnNext
{
get => base.OnNext;
set => ActionMerge(observer,value);
}
public override Action<Exception> OnError
{
get => base.OnError;
set => ActionMerge(observer,value);
}
public override Action OnComplete
{
get => base.OnComplete;
set => ActionMerge(observer,value);
}
public Action<T> ActionMerge(Action<T> a,Action<T> b)
{
return t =>
{
a(t);
b(t);
}
}
}
var subscribe = new ObserverSubscribe<BuilderOptions>(new UserObserver<T>());
var service = GetService(new BuilderOptions(),subscribe);