Skip to content
Snippets Groups Projects
Commit 759fdd31 authored by Loïc Correnson's avatar Loïc Correnson Committed by David Bühler
Browse files

[dome] optional forced update on GlobalStates

parent 978a687e
No related branches found
No related tags found
No related merge requests found
...@@ -107,9 +107,13 @@ export class GlobalState<A> { ...@@ -107,9 +107,13 @@ export class GlobalState<A> {
/** Current state value. */ /** Current state value. */
getValue(): A { return this.value; } getValue(): A { return this.value; }
/** Notify callbacks on change, using _deep_ structural comparison. */ /** Notify callbacks on change. By default, changed are detected
setValue(value: A): void { by using _deep_ structural comparison, using `react-fast-compare` comparison.
if (!isEqual(value, this.value)) { @param value the new value of the state
@param forced when set to `true`, notify callbacks without comparison.
*/
setValue(value: A, forced = false): void {
if (forced || !isEqual(value, this.value)) {
this.value = value; this.value = value;
this.emitter.emit(UPDATE, value); this.emitter.emit(UPDATE, value);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment