Observable that
Function
append
A array of new data to be added in this Subject.
Reference to it self.
Function
appendOne
new data to be added in this Subject.
Reference to it self.
Function
appendOneAt
new data to be added in this Subject.
index of where to append this data into the Subject.
Reference to it self.
Function
asObservable
Observable that the State casts to.
Function
createObservablePart
Method to return the part for this Observable to return.
OptionalmemoizationFunction: MemoizationFunction<ReturnType>
Method to compare two results. Should return true when data is the same (unchanged), preventing unnecessary emissions.
The derived Observable.
Function
getHasOne
the unique value to compare with.
Wether it existed
Function
prepend
A array of new data to be added in this Subject.
Reference to it self.
Function
remove
The unique values to remove.
Reference to it self.
Function
removeOne
The unique value to remove.
Reference to it self.
Function
replace
data of entries to be replaced.
Reference to it self.
const data = [
{ key: 1, value: 'foo'},
{ key: 2, value: 'bar'}
];
const myState = new UmbArrayState(data, (x) => x.key);
const updates = [
{ key: 1, value: 'foo2'},
{ key: 3, value: 'bar2'}
];
myState.replace(updates);
// Only the existing item gets replaced:
myState.getValue(); // -> [{ key: 1, value: 'foo2'}, { key: 2, value: 'bar'}]
UmbArrayState
Description
The ArrayState provides methods to append data when the data is an Object.
Constructing with an actual array keeps the classic, non-nullable behaviour (
getValue()returnsT[]). Constructing withundefined— or a value typed to includeundefined— makes the state nullable (getValue()returnsT[] | undefined). Note this detection only works when the generic parameters aren't pinned explicitly to justT; to opt into the nullable behaviour while still namingT, provide all three generics:new UmbArrayState<Item, unknown, undefined>(undefined, ...).