This commit is contained in:
Niels Lyngsø
2023-01-25 10:45:17 +01:00
parent dea113ec8b
commit 8bb409d2c9
2 changed files with 10 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ export class ArrayState<T> extends DeepState<T[]> {
/**
* @method append
* @param {unknown} unique - The unique value to remove.
* @returns ArrayState<T>
* @return {ArrayState<T>} Reference to it self.
* @description - Remove some new data of this Subject.
* @example <caption>Example remove entry with key '1'</caption>
* const data = [
@@ -51,7 +51,7 @@ export class ArrayState<T> extends DeepState<T[]> {
/**
* @method filter
* @param {unknown} filterMethod - The unique value to remove.
* @returns ArrayState<T>
* @return {ArrayState<T>} Reference to it self.
* @description - Remove some new data of this Subject.
* @example <caption>Example remove entry with key '1'</caption>
* const data = [
@@ -77,7 +77,7 @@ export class ArrayState<T> extends DeepState<T[]> {
/**
* @method appendOne
* @param {T} entry - new data to be added in this Subject.
* @returns ArrayState<T>
* @return {ArrayState<T>} Reference to it self.
* @description - Append some new data to this Subject.
* @example <caption>Example append some data.</caption>
* const data = [
@@ -101,7 +101,7 @@ export class ArrayState<T> extends DeepState<T[]> {
/**
* @method append
* @param {T[]} entries - A array of new data to be added in this Subject.
* @returns ArrayState<T>
* @return {ArrayState<T>} Reference to it self.
* @description - Append some new data to this Subject, if it compares to existing data it will replace it.
* @example <caption>Example append some data.</caption>
* const data = [

View File

@@ -12,15 +12,17 @@ import { DeepState } from "./deep-state";
export class ObjectState<T> extends DeepState<T> {
/**
* @method append
* @param {Partial<T>} partialData - A object containing some of the data for this Subject.
* @method update
* @param {Partial<T>} partialData - A object containing some of the data to update in this Subject.
* @description - Append some new data to this Object.
* @return {ObjectState<T>} Reference to it self.
* @example <caption>Example append some data.</caption>
* const data = {key: 'myKey', value: 'myInitialValue'};
* const mySubject = new ObjectState(data)
* mySubject.append({value: 'myNewValue'})
* const myState = new ObjectState(data);
* myState.update({value: 'myNewValue'});
*/
update(partialData: Partial<T>) {
this.next({ ...this.getValue(), ...partialData });
return this;
}
}