Class ReactiveProperty<T>
- Namespace
- ReactiveUI
- Assembly
- ReactiveUI.dll
ReactiveProperty - a two way bindable declarative observable property with imperative get set.
[DataContract]
public class ReactiveProperty<T> : ReactiveObject, IReactiveNotifyPropertyChanged<IReactiveObject>, IHandleObservableErrors, IReactiveObject, INotifyPropertyChanging, IEnableLogger, IReactiveProperty<T>, IObservable<T?>, ICancelable, IDisposable, INotifyDataErrorInfo, INotifyPropertyChanged
Type Parameters
TThe type of the property.
- Inheritance
-
ReactiveProperty<T>
- Implements
-
IEnable
Logger IObservable<T>ICancelable
- Inherited Members
- Extension Methods
-
ReactivePropertyMixins.AddValidation<T>(ReactiveProperty<T>, Expression<Func<ReactiveProperty<T>?>>)
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.
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.
Parameters
initialValueTThe initial value.
ReactiveProperty(T?, bool, bool)
Initializes a new instance of the ReactiveProperty<T> class.
public ReactiveProperty(T? initialValue, bool skipCurrentValueOnSubscribe, bool allowDuplicateValues)
Parameters
initialValueTThe initial value.
skipCurrentValueOnSubscribeboolif set to
true[skip current value on subscribe].allowDuplicateValuesboolif 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
initialValueTThe initial value.
schedulerISchedulerThe scheduler.
skipCurrentValueOnSubscribeboolif set to
true[skip current value on subscribe].allowDuplicateValuesboolif set to
true[allow duplicate concurrent values].
Properties
HasErrors
Gets a value indicating whether this instance has errors.
Property Value
- bool
trueif this instance has errors; otherwise,false.
IsDisposed
Gets a value indicating whether gets a value that indicates whether the object is disposed.
Property Value
ObserveErrorChanged
Gets the observe error changed.
Property Value
- IObservable<IEnumerable>
The observe error changed.
ObserveHasErrors
Gets the observe has errors.
Property Value
- IObservable<bool>
The observe has errors.
Value
Gets or sets the value.
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
validatorFunc<IObservable<T>, IObservable<IEnumerable>>If success return IO<null>, failure return IO<IEnumerable>(Errors).
ignoreInitialErrorboolif set to
true[ignore initial error].
Returns
- Reactive
Property <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
validatorFunc<IObservable<T>, IObservable<string>>If success return IO<null>, failure return IO<IEnumerable>(Errors).
ignoreInitialErrorboolif set to
true[ignore initial error].
Returns
- Reactive
Property <T> Self.
AddValidationError(Func<T?, IEnumerable?>, bool)
Set INotifyDataErrorInfo validation.
public ReactiveProperty<T> AddValidationError(Func<T?, IEnumerable?> validator, bool ignoreInitialError = false)
Parameters
validatorFunc<T, IEnumerable>Validation logic.
ignoreInitialErrorboolif set to
true[ignore initial error].
Returns
- Reactive
Property <T> Self.
AddValidationError(Func<T?, string?>, bool)
Set INotifyDataErrorInfo validation.
public ReactiveProperty<T> AddValidationError(Func<T?, string?> validator, bool ignoreInitialError = false)
Parameters
validatorFunc<T, string>Validation logic.
ignoreInitialErrorboolif set to
true[ignore initial error].
Returns
- Reactive
Property <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
validatorFunc<T, Task<IEnumerable>>Validation logic.
ignoreInitialErrorboolif set to
true[ignore initial error].
Returns
- Reactive
Property <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
validatorFunc<T, Task<string>>Validation logic.
ignoreInitialErrorboolif set to
true[ignore initial error].
Returns
- Reactive
Property <T> Self.
CheckValidation()
Check validation.
Create()
Creates a new instance of ReactiveProperty without requiring RequiresUnreferencedCode attributes. Uses RxSchedulers.TaskpoolScheduler as the default scheduler.
Returns
- Reactive
Property <T> A new ReactiveProperty instance.
Create(T?)
Creates a new instance of ReactiveProperty with an initial value without requiring RequiresUnreferencedCode attributes. Uses RxSchedulers.TaskpoolScheduler as the default scheduler.
Parameters
initialValueTThe initial value.
Returns
- Reactive
Property <T> A new ReactiveProperty instance.
Create(T?, bool, bool)
Creates a new instance of ReactiveProperty with configuration options without requiring RequiresUnreferencedCode attributes. Uses RxSchedulers.TaskpoolScheduler as the default scheduler.
public static ReactiveProperty<T> Create(T? initialValue, bool skipCurrentValueOnSubscribe, bool allowDuplicateValues)
Parameters
initialValueTThe initial value.
skipCurrentValueOnSubscribeboolif set to
true[skip current value on subscribe].allowDuplicateValuesboolif set to
true[allow duplicate concurrent values].
Returns
- Reactive
Property <T> A new ReactiveProperty instance.
Create(T?, IScheduler, bool, bool)
Creates a new instance of ReactiveProperty with a custom scheduler without requiring RequiresUnreferencedCode attributes.
public static ReactiveProperty<T> Create(T? initialValue, IScheduler scheduler, bool skipCurrentValueOnSubscribe, bool allowDuplicateValues)
Parameters
initialValueTThe initial value.
schedulerISchedulerThe scheduler.
skipCurrentValueOnSubscribeboolif set to
true[skip current value on subscribe].allowDuplicateValuesboolif set to
true[allow duplicate concurrent values].
Returns
- Reactive
Property <T> A new ReactiveProperty instance.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
Parameters
disposingbooltrueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetErrors(string?)
Gets the errors.
Parameters
propertyNamestringName of the property.
Returns
- IEnumerable
A IEnumerable.
Refresh()
Invoke OnNext.
Subscribe(IObserver<T?>)
Notifies the provider that an observer is to receive notifications.
Parameters
observerIObserver<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.