Interface ICreatesObservableForProperty
- Namespace
- ReactiveUI
- Assembly
- ReactiveUI.dll
ICreatesObservableForProperty represents an object that knows how to create notifications for a given type of object. Implement this if you are porting RxUI to a new UI toolkit, or generally want to enable WhenAny for another type of object that can be observed in a unique way.
- Extension Methods
Methods
GetAffinityForObject(Type, string, bool)
Returns a positive integer when this class supports GetNotificationForProperty for this particular Type. If the method isn't supported at all, return a non-positive integer. When multiple implementations return a positive value, the host will use the one which returns the highest value. When in doubt, return '2' or '0'.
[RequiresDynamicCode("GetAffinityForObject uses methods that require dynamic code generation")]
[RequiresUnreferencedCode("GetAffinityForObject uses methods that may require unreferenced code")]
int GetAffinityForObject(Type type, string propertyName, bool beforeChanged = false)
Parameters
typeTypeThe type to query for.
propertyNamestringThe property of the type to query for.
beforeChangedboolIf true, returns whether GNFP is supported before a change occurs.
Returns
- int
A positive integer if GNFP is supported, zero or a negative value otherwise.
GetNotificationForProperty(object, Expression, string, bool, bool)
Subscribe to notifications on the specified property, given an object and a property name.
[RequiresDynamicCode("GetNotificationForProperty uses methods that require dynamic code generation")]
[RequiresUnreferencedCode("GetNotificationForProperty uses methods that may require unreferenced code")]
IObservable<IObservedChange<object?, object?>> GetNotificationForProperty(object sender, Expression expression, string propertyName, bool beforeChanged = false, bool suppressWarnings = false)
Parameters
senderobjectThe object to observe.
expressionExpressionThe expression on the object to observe. This will be either a MemberExpression or an IndexExpression depending on the property.
propertyNamestringThe property of the type to query for.
beforeChangedboolIf true, signal just before the property value actually changes. If false, signal after the property changes.
suppressWarningsboolIf true, no warnings should be logged.
Returns
- IObservable<IObserved
Change <object, object>> An IObservable which is signaled whenever the specified property on the object changes. If this cannot be done for a specified value of beforeChanged, return Observable.Never.