Table of Contents

Class ReactiveProperty<T>

Namespace
ReactiveUI
Assembly
ReactiveUI.dll

ReactiveProperty - a two way bindable declarative observable property with imperative get set.

public class ReactiveProperty<T> : ReactiveObject, IReactiveNotifyPropertyChanged<IReactiveObject>, IHandleObservableErrors, IReactiveObject, INotifyPropertyChanging, IEnableLogger, IReactiveProperty<T>, IObservable<T?>, ICancelable, IDisposable, IDisposable, INotifyDataErrorInfo, INotifyPropertyChanged

Type Parameters

T

The type of the property.

Inheritance
ReactiveProperty<T>
Implements
ICancelable
Inherited Members
Extension Methods
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)

Constructors

ReactiveProperty()

Initializes a new instance of the ReactiveProperty<T> class. The Value will be default(T). DistinctUntilChanged is true. Current Value is published on subscribe.

public ReactiveProperty()

ReactiveProperty(T?)

Initializes a new instance of the ReactiveProperty<T> class. The Value will be initialValue. DistinctUntilChanged is true. Current Value is published on subscribe.

public ReactiveProperty(T? initialValue)

Parameters

initialValue T

The initial value.

ReactiveProperty(T?, bool, bool)

Initializes a new instance of the ReactiveProperty<T> class.

public ReactiveProperty(T? initialValue, bool skipCurrentValueOnSubscribe, bool allowDuplicateValues)

Parameters

initialValue T

The initial value.

skipCurrentValueOnSubscribe bool

if set to true [skip current value on subscribe].

allowDuplicateValues bool

if set to true [allow duplicate concurrent values].

ReactiveProperty(T?, IScheduler?, bool, bool)

Initializes a new instance of the ReactiveProperty<T> class.

public ReactiveProperty(T? initialValue, IScheduler? scheduler, bool skipCurrentValueOnSubscribe, bool allowDuplicateValues)

Parameters

initialValue T

The initial value.

scheduler IScheduler

The scheduler.

skipCurrentValueOnSubscribe bool

if set to true [skip current value on subscribe].

allowDuplicateValues bool

if set to true [allow duplicate concurrent values].

Properties

HasErrors

Gets a value indicating whether this instance has errors.

public bool HasErrors { get; }

Property Value

bool

true if this instance has errors; otherwise, false.

IsDisposed

Gets a value indicating whether gets a value that indicates whether the object is disposed.

public bool IsDisposed { get; }

Property Value

bool

ObserveErrorChanged

Gets the observe error changed.

public IObservable<IEnumerable?> ObserveErrorChanged { get; }

Property Value

IObservable<IEnumerable>

The observe error changed.

ObserveHasErrors

Gets the observe has errors.

public IObservable<bool> ObserveHasErrors { get; }

Property Value

IObservable<bool>

The observe has errors.

Value

Gets or sets the value.

[JsonInclude]
public T? Value { get; set; }

Property Value

T

The value.

Methods

AddValidationError(Func<IObservable<T?>, IObservable<IEnumerable?>>, bool)

Set INotifyDataErrorInfo's asynchronous validation, return value is self.

public ReactiveProperty<T> AddValidationError(Func<IObservable<T?>, IObservable<IEnumerable?>> validator, bool ignoreInitialError = false)

Parameters

validator Func<IObservable<T>, IObservable<IEnumerable>>

If success return IO<null>, failure return IO<IEnumerable>(Errors).

ignoreInitialError bool

if set to true [ignore initial error].

Returns

ReactiveProperty<T>

Self.

AddValidationError(Func<IObservable<T?>, IObservable<string?>>, bool)

Set INotifyDataErrorInfo's asynchronous validation, return value is self.

public ReactiveProperty<T> AddValidationError(Func<IObservable<T?>, IObservable<string?>> validator, bool ignoreInitialError = false)

Parameters

validator Func<IObservable<T>, IObservable<string>>

If success return IO<null>, failure return IO<IEnumerable>(Errors).

ignoreInitialError bool

if set to true [ignore initial error].

Returns

ReactiveProperty<T>

Self.

AddValidationError(Func<T?, IEnumerable?>, bool)

Set INotifyDataErrorInfo validation.

public ReactiveProperty<T> AddValidationError(Func<T?, IEnumerable?> validator, bool ignoreInitialError = false)

Parameters

validator Func<T, IEnumerable>

Validation logic.

ignoreInitialError bool

if set to true [ignore initial error].

Returns

ReactiveProperty<T>

Self.

AddValidationError(Func<T?, string?>, bool)

Set INotifyDataErrorInfo validation.

public ReactiveProperty<T> AddValidationError(Func<T?, string?> validator, bool ignoreInitialError = false)

Parameters

validator Func<T, string>

Validation logic.

ignoreInitialError bool

if set to true [ignore initial error].

Returns

ReactiveProperty<T>

Self.

AddValidationError(Func<T?, Task<IEnumerable?>>, bool)

Set INotifyDataErrorInfo's asynchronous validation.

public ReactiveProperty<T> AddValidationError(Func<T?, Task<IEnumerable?>> validator, bool ignoreInitialError = false)

Parameters

validator Func<T, Task<IEnumerable>>

Validation logic.

ignoreInitialError bool

if set to true [ignore initial error].

Returns

ReactiveProperty<T>

Self.

AddValidationError(Func<T?, Task<string?>>, bool)

Set INotifyDataErrorInfo's asynchronous validation.

public ReactiveProperty<T> AddValidationError(Func<T?, Task<string?>> validator, bool ignoreInitialError = false)

Parameters

validator Func<T, Task<string>>

Validation logic.

ignoreInitialError bool

if set to true [ignore initial error].

Returns

ReactiveProperty<T>

Self.

CheckValidation()

Check validation.

public void CheckValidation()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

GetErrors(string?)

Gets the errors.

public IEnumerable? GetErrors(string? propertyName)

Parameters

propertyName string

Name of the property.

Returns

IEnumerable

A IEnumerable.

Refresh()

Invoke OnNext.

public void Refresh()

Subscribe(IObserver<T?>)

Notifies the provider that an observer is to receive notifications.

public IDisposable Subscribe(IObserver<T?> observer)

Parameters

observer IObserver<T>

The object that is to receive notifications.

Returns

IDisposable

A reference to an interface that allows observers to stop receiving notifications before the provider has finished sending them.

Events

ErrorsChanged

public event EventHandler<DataErrorsChangedEventArgs>? ErrorsChanged

Event Type

EventHandler<DataErrorsChangedEventArgs>

See Also