Skip to content

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, netstandard2.0, net462, net471

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

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

Type parameters

NameDescription
TObjectThe type of the object (must implement INotifyPropertyChanged).
TKeyThe type of the key.
TValueThe type of the monitored property.

Parameters

NameTypeDescription
sourceIObservable>The source IObservable<IChangeSet<TObject, TKey>> to observe a specific property on items in.
propertyAccessorExpression>A Expression that expression selecting the property to monitor.
notifyOnInitialValue = trueboolWhen true (the default), the current property value is emitted immediately for each item upon subscription.

Returns: IObservable> -- 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