A array of new data to be added in this Subject.
Reference to it self.
append
const data = [
{ key: 1, value: 'foo'},
{ key: 2, value: 'bar'}
];
const myState = new UmbArrayState(data);
myState.append([
{ key: 1, value: 'replaced-foo'},
{ key: 3, value: 'another-bla'}
]);
new data to be added in this Subject.
Reference to it self.
new data to be added in this Subject.
index of where to append this data into the Subject.
Reference to it self.
Observable that the State casts to.
asObservable
const myState = new UmbArrayState('Hello world');
this.observe(myState, (latestStateValue) => console.log("Value is: ", latestStateValue));
Method to return the part for this Observable to return.
Optional
memoizationFunction: MemoizationFunction<ReturnType>Method to Compare if the data has changed. Should return true when data is different.
Reference to it self.
filter
const data = [
{ key: 1, value: 'foo'},
{ key: 2, value: 'bar'},
{ key: 3, value: 'poo'}
];
const myState = new UmbArrayState(data, (x) => x.key);
myState.filter((entry) => entry.key !== 1);
Result:
[
{ key: 2, value: 'bar'},
{ key: 3, value: 'poo'}
]
The unique values to remove.
Reference to it self.
The unique value to remove.
Reference to it self.
setValue
const myState = new UmbArrayState('Good morning');
// myState.value is equal 'Good morning'.
myState.setValue('Goodnight')
// myState.value is equal 'Goodnight'.
Unique value to find entry to update.
new data to be added in this Subject.
Reference to it self.
updateOne
const data = [
{ key: 1, value: 'foo'},
{ key: 2, value: 'bar'}
];
const myState = new UmbArrayState(data, (x) => x.key);
myState.updateOne(2, {value: 'updated-bar'});
UmbArrayState
Description
The ArrayState provides methods to append data when the data is an Object.