We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f5ab7c2 commit 17968ebCopy full SHA for 17968eb
src/utils/observable.utils.ts
@@ -1,4 +1,4 @@
1
-export type Observer<T> = (data: T) => void;
+export type Observer<T> = (next: T, prev?: T) => void;
2
export type UpdateFunction<T> = (state: T) => T;
3
export type Updater<T> = T | UpdateFunction<T>;
4
@@ -72,6 +72,17 @@ export class ObservableState<T> extends Observable<T> {
72
private readonly _mutable: boolean;
73
private _state: T;
74
75
+ /**
76
+ * Notifies all observers with optional data and previous state.
77
+ *
78
+ * @protected
79
+ * @param {T} data - The new data to be sent to observers.
80
+ * @memberof Observable
81
+ */
82
+ protected _notify(data: T) {
83
+ this._observers.forEach(observer => observer(data, this._state));
84
+ }
85
+
86
/**
87
* Gets the current state of the observable.
88
*
0 commit comments