Skip to content

Applies to

net10.0, netstandard2.0

public static IObservable<PropertyValue<TObject, TValue>> WhenPropertyChanged<TObject, TKey, TValue>(this IObservable<IChangeSet<TObject, TKey>> source, Expression<Func<TObject, TValue>> propertyAccessor, bool notifyOnInitialValue = true) where TObject : INotifyPropertyChanged where TKey : notnull

View source (opens in a new tab)

Summary: Emits a PropertyValue (item + property value) whenever the specified property changes on any item in the cache. Subscribes via INotifyPropertyChanged (opens in a new tab) using MergeMany.

Type parameters

NameDescription
TObjectThe type of the object (must implement INotifyPropertyChanged (opens in a new tab)).
TKeyThe type of the key.
TValueThe type of the monitored property.

Parameters

NameTypeDescription
sourceIObservable> (opens in a new tab)The source IObservable&lt;IChangeSet&lt;TObject, TKey&gt;&gt; to observe a specific property on items in.
propertyAccessorExpression> (opens in a new tab)A Expression (opens in a new tab) that expression selecting the property to monitor.
notifyOnInitialValue = truebool (opens in a new tab)When true (the default), the current property value is emitted immediately for each item upon subscription.

Returns: IObservable> (opens in a new tab) -- An observable of PropertyValue containing both the item and its property value.

Remarks

Per-item subscriptions are created on Add, replaced on Update, disposed on Remove. Errors from individual property subscriptions are silently ignored. The output is not a changeset stream. If you only need the value (not the owning item), use WhenValueChanged instead.

EventBehavior
AddSubscribes to the specified property on the new item. If notifyOnInitialValue is true, the current value is emitted immediately.
UpdateDisposes the old item's property subscription and subscribes to the new item.
RemoveDisposes the item's property subscription. No further emissions for this item.
RefreshNo effect on subscriptions. The existing property subscription continues.
OnErrorPer-item property subscription errors are silently ignored. Source errors terminate the stream.

See also