From 759fdd310232f22724d5a828cfb8b16a55ad52ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loi=CC=88c=20Correnson?= <loic.correnson@cea.fr> Date: Fri, 2 Dec 2022 12:14:12 +0100 Subject: [PATCH] [dome] optional forced update on GlobalStates --- ivette/src/dome/renderer/data/states.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ivette/src/dome/renderer/data/states.ts b/ivette/src/dome/renderer/data/states.ts index 69054cc7bf9..cb2aba5085d 100644 --- a/ivette/src/dome/renderer/data/states.ts +++ b/ivette/src/dome/renderer/data/states.ts @@ -107,9 +107,13 @@ export class GlobalState<A> { /** Current state value. */ getValue(): A { return this.value; } - /** Notify callbacks on change, using _deep_ structural comparison. */ - setValue(value: A): void { - if (!isEqual(value, this.value)) { + /** Notify callbacks on change. By default, changed are detected + by using _deep_ structural comparison, using `react-fast-compare` comparison. + @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.emitter.emit(UPDATE, value); } -- GitLab