This commit is contained in:
Niels Lyngsø
2023-04-03 15:26:29 +02:00
parent 5b6f3004ca
commit d4b369b9c2
2 changed files with 10 additions and 10 deletions

View File

@@ -6,8 +6,8 @@
* @param {(previousResult: R, currentResult: R) => boolean} [memoizationFunction] - Method to Compare if the data has changed. Should return true when data is different.
* @description - Creates a RxJS Observable from RxJS Subject.
* @example <caption>Example append new entry for a ArrayState or a part of DeepState/ObjectState it which is an array. Where the key is unique and the item will be updated if matched with existing.</caption>
* const entry = {key: 'myKey', value: 'myValue'};
* const newDataSet = appendToFrozenArray(mySubject.getValue(), entry, x => x.key === key);
* const entry = {id: 'myKey', value: 'myValue'};
* const newDataSet = appendToFrozenArray(mySubject.getValue(), entry, x => x.id === id);
* mySubject.next(newDataSet);
*/
export function appendToFrozenArray<T>(data: T[], entry: T, getUniqueMethod?: (entry: T) => unknown): T[] {

View File

@@ -50,12 +50,12 @@ export class ArrayState<T> extends DeepState<T[]> {
* @param {unknown[]} uniques - The unique values to remove.
* @return {ArrayState<T>} Reference to it self.
* @description - Remove some new data of this Subject.
* @example <caption>Example remove entry with key '1' and '2'</caption>
* @example <caption>Example remove entry with id '1' and '2'</caption>
* const data = [
* { key: 1, value: 'foo'},
* { key: 2, value: 'bar'}
* { id: 1, value: 'foo'},
* { id: 2, value: 'bar'}
* ];
* const myState = new ArrayState(data, (x) => x.key);
* const myState = new ArrayState(data, (x) => x.id);
* myState.remove([1, 2]);
*/
remove(uniques: unknown[]) {
@@ -79,12 +79,12 @@ export class ArrayState<T> extends DeepState<T[]> {
* @param {unknown} unique - The unique value to remove.
* @return {ArrayState<T>} Reference to it self.
* @description - Remove some new data of this Subject.
* @example <caption>Example remove entry with key '1'</caption>
* @example <caption>Example remove entry with id '1'</caption>
* const data = [
* { key: 1, value: 'foo'},
* { key: 2, value: 'bar'}
* { id: 1, value: 'foo'},
* { id: 2, value: 'bar'}
* ];
* const myState = new ArrayState(data, (x) => x.key);
* const myState = new ArrayState(data, (x) => x.id);
* myState.removeOne(1);
*/
removeOne(unique: unknown) {