public IDisposable Subscribe(IObserver <Func <T> > observer) { IDisposable subscription = this.owner.lazyPropertyChangeStream.Subscribe(observer); ObservableExpression.PushValueInUpToDateContext(() => observer.OnNext(this.owner.observedExpressionCompiled)); return(subscription); }
public IDisposable Subscribe(IObserver <T> observer) { //First, subscribe the observer, so that property handlers are attached. //This is important in case of a cyclic reference. Without handlers in //place cyclic referencing would not occur, even though it should. //Then, publish a value immediately, so that an initial value can be set. //Notice the current value is only passed to the new observer. //Subscribers present until now are NOT given this value again. IDisposable subscription = this.propertyChangeStream.Subscribe(observer); ObservableExpression.PushValueInUpToDateContext(() => observer.OnNext(this.observedExpressionCompiled())); //try //{ //observer.OnNext(this.observedExpressionCompiled()); //} //catch (Exception ex) //{ //} return(subscription); }
/// <summary> /// Initializes a new instance of the <see cref="T:LazyChannel"/> class. /// </summary> public LazyChannel(ObservableExpression <T> owner) { this.owner = owner; }