ReadOnlyObservableCollection
API / ReadOnlyObservableCollection<TItem> class
Represents a read-only observable collection which can be used as a base class for custom observable collections as well.
Extends: ViewModel, implements IReadOnlyObservableCollection<TItem>.
class ReadOnlyObservableCollection<TItem> extends ViewModel implements IReadOnlyObservableCollection<TItem>
- TItem: the type of items the collection contains.
- constructor: initializes a new instance of the ReadOnlyObservableCollection<TItem> class.
- itemAdded: an event that is raised when an item is added to the collection.
- itemRemoved: an event that is raised when an item is removed from the collection.
- collectionChanged: an event that is raised when the collection changed.
- length: gets the number of items in the collection.
-
@unscopables: Returns an object specifying how properties are handled inside a
with
statement.
- at: gets the item at the provided index.
- concat: merges the current collection with the given Array(s) and returns a new JavaScript Array.
-
join: aggregates the contained items into a String placing the provided
separator
between them. -
slice: returns a new JavaScript Array containing the elements starting at the provided
start
index up to, but not including, the providedend
index. -
indexOf: returns the first index of an item, or
-1
if none can be found. -
lastIndexOf: returns the last index of an item, or
-1
if none can be found. - every: checks whether all elements in the collection fulfil a given condition.
- some: checks whether some elements in the collection fulfil a given condition.
- forEach: executes the given callback for each item in the collection.
- map: creates a new JavaScript Array constructed by mapping each item in the collection using a callback.
-
filter: creates a new JavaScript Array containing only the items for which the provided
predicate
evaluates totrue
. - reduce: aggregates the collection to a single value.
- reduceRight: aggregates the collection to a single value by iterating the collection from end to start.
-
find: returns the first item for which the provided
predicate
evaluated totrue
, if no item can be found thenundefined
is returned. -
findLast: returns the last item for which the provided
predicate
evaluated totrue
, if no item can be found thenundefined
is returned. -
findIndex: returns the index of the first item for which the provided
predicate
evaluated totrue
, if no item can be found then-1
is returned. -
findLastIndex: returns the index of the last item for which the provided
predicate
evaluated totrue
, if no item can be found then-1
is returned. - entries: returns an Array iterator containing all the index/item pairs in the collection.
- keys: returns an Array iterator containing all the indexes in the collection.
- values: returns an Array iterator containing all the items in the collection.
- includes: checks whether the provided item is contained by the collection.
- flatMap: returns a new JavaScript Array by mapping all items in the collection and the flattening the result by one level.
- flat: returns a new JavaScript Array containing the flattened sub-arrays by recursively concatenating them.
- toReversed: Returns a JavaScript Array containing the items of the collection in reverse order.
- toSorted: Returns a JavaScript Array containing the items of the collection in ascending order.
- toSpliced: Returns a JavaScript Array containing the spliced items of the collection.
- with: Returns a JavaScript Array containing the elements from the collection and having the one at the provided index replaced with the provided value.
- @iterator: returns an Array iterator containing all the items in the collection.
- toArray: Converts the observable collection to a native JavaScript Array.
- push: appends new elements to the end of the collection, and returns the new length of the collection.
-
pop: removes the last element from the collection and returns it. If the collection is empty,
undefined
is returned. - unshift: inserts new elements at the start of the collection, and returns the new length of the collection.
-
shift: removes the first element from the collection and returns it. If the collection is empty,
undefined
is returned. - get: gets the item at the provided index.
- set: sets the provided item at the provided index.
- splice: removes and/or adds elements to the collection and returns the deleted elements.
-
clear: Clears the contents of the collection and returns the removed items, similar to calling
collection.splice(0)
. -
reset: resets the contents of the collection by clearing it and setting the provided items. Returns the new length of the collection. Similar to calling
collection.splice(0, collection.length, ...items)
.
Motivation
Overview
Guides and Tutorials - Getting Started
Releases
API
Events
IEvent
IEventHandler
INotifyPropertiesChanged
INotifyCollectionChanged
IItemAddedEventArgs
IItemRemovedEventArgs
ICollectionChange
ItemRemovedCallback
ICollectionChange
EventDispatcher
Observable Collections
IReadOnlyObservableCollection
IObservableCollection
ReadOnlyObservableCollection
ObservableCollection
ViewModels
ViewModel
isViewModel
Forms
IFormFieldViewModel
IFormFieldViewModelConfig
FormFieldViewModel
FormFieldCollectionViewModel
FormFieldSet
DynamicFormFieldCollectionViewModel
Validation
IReadOnlyValidatable
IValidatable
IValidationConfig
ValidatorCallback
CollectionItemValidatorCallback
ValidatableSelectorCallback
ValidationConfigSelectorCallback
UnsubscribeCallback
registerValidators
registerCollectionValidators
registerCollectionItemValidators
React Hooks
EventHandler
useEvent
ViewModelType
ViewModelFactory
useViewModel
useViewModelMemo
useObservableCollection
useValidators
useCollectionValidators
useCollectionItemValidators