Class AutoPersistHelper
- Namespace
- ReactiveUI
- Assembly
- ReactiveUI.dll
Helper extension method class associated with the AutoPersist related functionality.
- Inheritance
-
Auto
Persist Helper
Methods
ActOnEveryObject<TItem>(ObservableCollection<TItem>, Action<TItem>, Action<TItem>)
Call methods 'onAdd' and 'onRemove' whenever an object is added or removed from a collection. This class correctly handles both when a collection is initialized, as well as when the collection is Reset.
public static IDisposable ActOnEveryObject<TItem>(this ObservableCollection<TItem> @this, Action<TItem> onAdd, Action<TItem> onRemove) where TItem : IReactiveObject
Parameters
this
ObservableCollection <TItem>The reactive collection to watch for changes.
onAdd
Action<TItem>A method to be called when an object is added to the collection.
onRemove
Action<TItem>A method to be called when an object is removed from the collection.
Returns
- IDisposable
A Disposable that deactivates this behavior.
Type Parameters
TItem
The item type.
ActOnEveryObject<TItem>(ReadOnlyObservableCollection<TItem>, Action<TItem>, Action<TItem>)
Call methods 'onAdd' and 'onRemove' whenever an object is added or removed from a collection. This class correctly handles both when a collection is initialized, as well as when the collection is Reset.
public static IDisposable ActOnEveryObject<TItem>(this ReadOnlyObservableCollection<TItem> @this, Action<TItem> onAdd, Action<TItem> onRemove) where TItem : IReactiveObject
Parameters
this
ReadOnly <TItem>Observable Collection The reactive collection to watch for changes.
onAdd
Action<TItem>A method to be called when an object is added to the collection.
onRemove
Action<TItem>A method to be called when an object is removed from the collection.
Returns
- IDisposable
A Disposable that deactivates this behavior.
Type Parameters
TItem
The item type.
ActOnEveryObject<TItem>(IObservable<IChangeSet<TItem>>, Action<TItem>, Action<TItem>)
Call methods 'onAdd' and 'onRemove' whenever an object is added or removed from a collection. This class correctly handles both when a collection is initialized, as well as when the collection is Reset.
public static IDisposable ActOnEveryObject<TItem>(this IObservable<IChangeSet<TItem>> @this, Action<TItem> onAdd, Action<TItem> onRemove) where TItem : IReactiveObject
Parameters
this
IObservable<IChangeSet <TItem>>The reactive collection to watch for changes.
onAdd
Action<TItem>A method to be called when an object is added to the collection.
onRemove
Action<TItem>A method to be called when an object is removed from the collection.
Returns
- IDisposable
A Disposable that deactivates this behavior.
Type Parameters
TItem
The item type.
ActOnEveryObject<TItem, TCollection>(TCollection, Action<TItem>, Action<TItem>)
Call methods 'onAdd' and 'onRemove' whenever an object is added or removed from a collection. This class correctly handles both when a collection is initialized, as well as when the collection is Reset.
public static IDisposable ActOnEveryObject<TItem, TCollection>(this TCollection collection, Action<TItem> onAdd, Action<TItem> onRemove) where TItem : IReactiveObject where TCollection : INotifyCollectionChanged, IEnumerable<TItem>
Parameters
collection
TCollectionThe reactive collection to watch for changes.
onAdd
Action<TItem>A method to be called when an object is added to the collection.
onRemove
Action<TItem>A method to be called when an object is removed from the collection.
Returns
- IDisposable
A Disposable that deactivates this behavior.
Type Parameters
TItem
The item type.
TCollection
The collection type.
AutoPersistCollection<TItem>(ObservableCollection<TItem>, Func<TItem, IObservable<Unit>>, TimeSpan?)
Apply AutoPersistence to all objects in a collection. Items that are no longer in the collection won't be persisted anymore.
public static IDisposable AutoPersistCollection<TItem>(this ObservableCollection<TItem> @this, Func<TItem, IObservable<Unit>> doPersist, TimeSpan? interval = null) where TItem : IReactiveObject
Parameters
this
ObservableCollection <TItem>The reactive collection to watch for changes.
doPersist
Func<TItem, IObservable<Unit>>The asynchronous method to call to save the object to disk.
interval
TimeSpan ?The interval to save the object on. Note that if an object is constantly changing, it is possible that it will never be saved.
Returns
- IDisposable
A Disposable to disable automatic persistence.
Type Parameters
TItem
The item type.
AutoPersistCollection<TItem, TDontCare>(ObservableCollection<TItem>, Func<TItem, IObservable<Unit>>, IObservable<TDontCare>, TimeSpan?)
Apply AutoPersistence to all objects in a collection. Items that are no longer in the collection won't be persisted anymore.
public static IDisposable AutoPersistCollection<TItem, TDontCare>(this ObservableCollection<TItem> @this, Func<TItem, IObservable<Unit>> doPersist, IObservable<TDontCare> manualSaveSignal, TimeSpan? interval = null) where TItem : IReactiveObject
Parameters
this
ObservableCollection <TItem>The reactive collection to watch for changes.
doPersist
Func<TItem, IObservable<Unit>>The asynchronous method to call to save the object to disk.
manualSaveSignal
IObservable<TDontCare>When invoked, the object will be saved regardless of whether it has changed.
interval
TimeSpan ?The interval to save the object on. Note that if an object is constantly changing, it is possible that it will never be saved.
Returns
- IDisposable
A Disposable to disable automatic persistence.
Type Parameters
TItem
The item type.
TDontCare
The return signal type.
AutoPersistCollection<TItem, TDontCare>(ReadOnlyObservableCollection<TItem>, Func<TItem, IObservable<Unit>>, IObservable<TDontCare>, TimeSpan?)
Apply AutoPersistence to all objects in a collection. Items that are no longer in the collection won't be persisted anymore.
public static IDisposable AutoPersistCollection<TItem, TDontCare>(this ReadOnlyObservableCollection<TItem> @this, Func<TItem, IObservable<Unit>> doPersist, IObservable<TDontCare> manualSaveSignal, TimeSpan? interval = null) where TItem : IReactiveObject
Parameters
this
ReadOnly <TItem>Observable Collection The reactive collection to watch for changes.
doPersist
Func<TItem, IObservable<Unit>>The asynchronous method to call to save the object to disk.
manualSaveSignal
IObservable<TDontCare>When invoked, the object will be saved regardless of whether it has changed.
interval
TimeSpan ?The interval to save the object on. Note that if an object is constantly changing, it is possible that it will never be saved.
Returns
- IDisposable
A Disposable to disable automatic persistence.
Type Parameters
TItem
The item type.
TDontCare
The signal type.
AutoPersistCollection<TItem, TCollection, TDontCare>(TCollection, Func<TItem, IObservable<Unit>>, IObservable<TDontCare>, TimeSpan?)
Apply AutoPersistence to all objects in a collection. Items that are no longer in the collection won't be persisted anymore.
public static IDisposable AutoPersistCollection<TItem, TCollection, TDontCare>(this TCollection @this, Func<TItem, IObservable<Unit>> doPersist, IObservable<TDontCare> manualSaveSignal, TimeSpan? interval = null) where TItem : IReactiveObject where TCollection : INotifyCollectionChanged, IEnumerable<TItem>
Parameters
this
TCollectionThe reactive collection to watch for changes.
doPersist
Func<TItem, IObservable<Unit>>The asynchronous method to call to save the object to disk.
manualSaveSignal
IObservable<TDontCare>When invoked, the object will be saved regardless of whether it has changed.
interval
TimeSpan ?The interval to save the object on. Note that if an object is constantly changing, it is possible that it will never be saved.
Returns
- IDisposable
A Disposable to disable automatic persistence.
Type Parameters
TItem
The item type.
TCollection
The collection type.
TDontCare
The signal type.
AutoPersist<T>(T, Func<T, IObservable<Unit>>, TimeSpan?)
AutoPersist allows you to automatically call a method when an object has changed, throttling on a certain interval. Note that this object must mark its persistent properties via the [DataMember] attribute. Changes to properties not marked with DataMember will not trigger the object to be saved.
public static IDisposable AutoPersist<T>(this T @this, Func<T, IObservable<Unit>> doPersist, TimeSpan? interval = null) where T : IReactiveObject
Parameters
this
TThe reactive object to watch for changes.
doPersist
Func<T, IObservable<Unit>>The asynchronous method to call to save the object to disk.
interval
TimeSpan ?The interval to save the object on. Note that if an object is constantly changing, it is possible that it will never be saved.
Returns
- IDisposable
A Disposable to disable automatic persistence.
Type Parameters
T
The reactive object type.
AutoPersist<T, TDontCare>(T, Func<T, IObservable<Unit>>, IObservable<TDontCare>, TimeSpan?)
AutoPersist allows you to automatically call a method when an object has changed, throttling on a certain interval. Note that this object must mark its persistent properties via the [DataMember] attribute. Changes to properties not marked with DataMember will not trigger the object to be saved.
public static IDisposable AutoPersist<T, TDontCare>(this T @this, Func<T, IObservable<Unit>> doPersist, IObservable<TDontCare> manualSaveSignal, TimeSpan? interval = null) where T : IReactiveObject
Parameters
this
TThe reactive object to watch for changes.
doPersist
Func<T, IObservable<Unit>>The asynchronous method to call to save the object to disk.
manualSaveSignal
IObservable<TDontCare>When invoked, the object will be saved regardless of whether it has changed.
interval
TimeSpan ?The interval to save the object on. Note that if an object is constantly changing, it is possible that it will never be saved.
Returns
- IDisposable
A Disposable to disable automatic persistence.
Type Parameters
T
The reactive object type.
TDontCare
The save signal type.