Class ObservableForPropertyBase
- Namespace
- ReactiveUI
- Assembly
- ReactiveUI.dll
ObservableForPropertyBase 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.
public abstract class ObservableForPropertyBase : Object, ICreatesObservableForProperty, IEnableLogger
- Inheritance
-
ObservableForPropertyBase
- Implements
- Derived
- Extension Methods
Constructors
ObservableForPropertyBase()
protected ObservableForPropertyBase()
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'.
public int GetAffinityForObject(Type type, string propertyName, bool beforeChanged = false)
Parameters
type
TypeThe type to query for.
propertyName
stringThe property of the type to query for.
beforeChanged
boolIf 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.
public IObservable<IObservedChange<object, object?>> GetNotificationForProperty(object sender, Expression expression, string propertyName, bool beforeChanged = false, bool suppressWarnings = false)
Parameters
sender
objectThe object to observe.
expression
ExpressionThe expression on the object to observe. This will be either a MemberExpression or an IndexExpression depending on the property.
propertyName
stringThe property of the type to query for.
beforeChanged
boolIf true, signal just before the property value actually changes. If false, signal after the property changes.
suppressWarnings
boolIf true, no warnings should be logged.
Returns
- IObservable<IObservedChange<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.
ObservableFromEvent(NSObject, Expression, string)
Creates an Observable for a NSNotificationCenter notification.
protected static IObservable<IObservedChange<object, object?>> ObservableFromEvent(NSObject sender, Expression expression, string eventName)
Parameters
sender
NSObjectSender.
expression
ExpressionThe expression.
eventName
stringThe event name.
Returns
- IObservable<IObservedChange<object, object>>
The from notification.
ObservableFromNotification(NSObject, Expression, NSString)
Creates an Observable for a NSNotificationCenter notification.
protected static IObservable<IObservedChange<object, object?>> ObservableFromNotification(NSObject sender, Expression expression, NSString notification)
Parameters
sender
NSObjectSender.
expression
ExpressionExpression.
notification
NSStringNotification.
Returns
- IObservable<IObservedChange<object, object>>
The from notification.
ObservableFromUIControlEvent(NSObject, Expression, UIControlEvent)
Creates an Observable for a UIControl Event.
protected static IObservable<IObservedChange<object, object?>> ObservableFromUIControlEvent(NSObject sender, Expression expression, UIControlEvent evt)
Parameters
sender
NSObjectThe sender.
expression
ExpressionThe expression.
evt
UIControlEventThe control event to listen for.
Returns
- IObservable<IObservedChange<object, object>>
An observable.
Register(Type, string, int, Func<NSObject, Expression, IObservable<IObservedChange<object, object?>>>)
Registers an observable factory for the specified type and property.
protected void Register(Type type, string property, int affinity, Func<NSObject, Expression, IObservable<IObservedChange<object, object?>>> createObservable)
Parameters
type
TypeType.
property
stringProperty.
affinity
intAffinity.
createObservable
Func<NSObject, Expression, IObservable<IObservedChange<object, object>>>Create observable.