Skip to content

ReactiveList class

Attributes: [DefaultMember("Item")] [DebuggerDisplay("Count = {Count}")]

Defined in

Namespace: ReactiveList.Reactive.Collections Assembly: ReactiveList.Reactive.dll Full name: ReactiveList.Reactive.Collections.ReactiveList<T> Modifiers: public sealed

Summary

View source (opens in a new tab)

        Represents a thread-safe, observable list that provides reactive notifications for item additions, removals, and
        changes.

Applies to

net11.0, net10.0, net47, net471, net472, net48, net481

Class hierarchy
classDiagram
class ReactiveList~T~
class IReactiveList~T~ {
    <>
}
IReactiveList~T~ <|.. ReactiveList~T~
class IList~T~ {
    <>
}
IList~T~ <|.. ReactiveList~T~
class ICollection~T~ {
    <>
}
ICollection~T~ <|.. ReactiveList~T~
class IEnumerable~T~ {
    <>
}
IEnumerable~T~ <|.. ReactiveList~T~
class IEnumerable {
    <>
}
IEnumerable <|.. ReactiveList~T~
class IList {
    <>
}
IList <|.. ReactiveList~T~
class ICollection {
    <>
}
ICollection <|.. ReactiveList~T~
class IReadOnlyList~T~ {
    <>
}
IReadOnlyList~T~ <|.. ReactiveList~T~
class IReadOnlyCollection~T~ {
    <>
}
IReadOnlyCollection~T~ <|.. ReactiveList~T~
class IReactiveSource~T~ {
    <>
}
IReactiveSource~T~ <|.. ReactiveList~T~
class INotifyCollectionChanged {
    <>
}
INotifyCollectionChanged <|.. ReactiveList~T~
class IDisposable {
    <>
}
IDisposable <|.. ReactiveList~T~
class INotifyPropertyChanged {
    <>
}
INotifyPropertyChanged <|.. ReactiveList~T~
class IReactiveSourceWithOptions {
    <>
}
IReactiveSourceWithOptions <|.. ReactiveList~T~
class IVersionedSnapshotSource~T~ {
    <>
}
IVersionedSnapshotSource~T~ <|.. ReactiveList~T~

Implements: IReactiveList, IList (opens in a new tab), ICollection (opens in a new tab), IEnumerable (opens in a new tab), IEnumerable (opens in a new tab), IList (opens in a new tab), ICollection (opens in a new tab), IReadOnlyList (opens in a new tab), IReadOnlyCollection (opens in a new tab), IReactiveSource, INotifyCollectionChanged (opens in a new tab), IDisposable (opens in a new tab), INotifyPropertyChanged (opens in a new tab), IReactiveSourceWithOptions, IVersionedSnapshotSource

Remarks

All public members are thread-safe. Mutations are applied under an internal lock, and notifications (CollectionChanged, PropertyChanged, Stream, CurrentItems and the observable collections) are queued in commit order and delivered after the lock is released by one thread at a time. A mutation made from inside a handler is therefore applied immediately but its notifications are delivered after the current handler returns, and a mutation made while another thread is delivering may return before its own notifications have been delivered. Predicates passed to RemoveMany and the action passed to Edit run under the lock, must not block on other threads, and must not mutate the list.

Constructors

NameSummary
.ctorInitializes a new instance of the ReactiveList class.

Properties

NameSummary
CountGets the number of elements contained in the list.
IsDisposedGets a value indicating whether the source has been disposed.
IsFixedSizeGets a value indicating whether the IList (opens in a new tab) has a fixed size.
IsReadOnlyGets a value indicating whether the list is read-only.
IsSynchronizedGets a value indicating whether access to the ICollection (opens in a new tab) is synchronized (thread safe).
OptionsGets the options that apply for the lifetime of the source.
VersionGets the current version number of the collection, which is incremented on each modification.
SyncRootGets an object that can be used to synchronize access to the ICollection (opens in a new tab).
this[]Gets or sets the element at the specified index.
AddedGets the added during the last change as an Observable.
ChangedGets the changed during the last change as an Observable.
CurrentItemsGets the current items as an observable that replays the latest snapshot to new subscribers.
RemovedGets the removed items during the last change as an Observable.
ItemsGets a read-only observable mirror of the items.
ItemsAddedGets the items added during the last change.
ItemsChangedGets the items changed during the last change.
ItemsRemovedGets the items removed during the last change.
StreamGets an observable sequence that emits cache change notifications as they occur.
VersionedStreamGets an observable of change notifications, each paired with the version the change produced.

Methods

NameSummary
AddAdds an item to the ICollection (opens in a new tab).
ToArrayCreates a snapshot of current items as an array.
CopyVersionedCopies every item and reports the version of that copy.
AddRangeAdds a range of items from a ReadOnlySpan (opens in a new tab).
CopyToCopies the items to the specified span.
AsSpanGets a read-only span over a snapshot of the items.
AsMemoryGets a read-only memory region over a snapshot of the items.
ClearWithoutDeallocationClears all items from the list; the internal array capacity is kept for reuse.
ClearRemoves all items from the ICollection (opens in a new tab).
ContainsDetermines whether the ICollection (opens in a new tab) contains a specific value.
EditApplies several changes as one notification.
GetEnumeratorReturns an enumerator that iterates through the list.
IndexOfDetermines the index of a specific item in the IList (opens in a new tab).
InsertInserts an item to the IList (opens in a new tab) at the specified index.
InsertRangeInserts a range of items at an index.
MoveMoves an item from one index to another.
RemoveRemoves the first occurrence of a specific object from the ICollection (opens in a new tab).
RemoveManyRemoves all elements that match the specified predicate from the collection.
RemoveAtRemoves the IList (opens in a new tab) item at the specified index.
RemoveRangeRemoves the range.
ReplaceAllReplaces all existing items with new items.
UpdateUpdates the specified item.
DisposeReleases the stream and observable resources; calling it more than once, or from several threads, is safe.
DeferNotificationsDefers change notifications until the last active deferral is disposed.
SubscribeSubscribes the specified observer to the CurrentItems.

Events

NameSummary
CollectionChangedOccurs when the collection changes.
PropertyChangedOccurs when a property value changes.
Inherited members