From 7a2c1f27ed94c8bcbc57520df74bd034f758b472 Mon Sep 17 00:00:00 2001 From: Guido Modarelli Date: Thu, 12 Dec 2024 12:19:59 -0300 Subject: [PATCH] fix(types): update createHooks to handle optional updater$ for better robustness in state management functionality --- plugins/wazuh-core/public/services/state/hooks/creator.ts | 2 +- plugins/wazuh-core/public/services/state/types.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/wazuh-core/public/services/state/hooks/creator.ts b/plugins/wazuh-core/public/services/state/hooks/creator.ts index 998d23fb20..f8417e4ecb 100644 --- a/plugins/wazuh-core/public/services/state/hooks/creator.ts +++ b/plugins/wazuh-core/public/services/state/hooks/creator.ts @@ -4,7 +4,7 @@ import { State } from '../types'; export const createHooks = ({ state }: { state: State }) => { function useStateContainer(name: string) { const value: T = useObservable( - state.getStateContainer(name).updater$, + state.getStateContainer(name)?.updater$, state.get(name), ); diff --git a/plugins/wazuh-core/public/services/state/types.ts b/plugins/wazuh-core/public/services/state/types.ts index d80347ca1a..a1a309de61 100644 --- a/plugins/wazuh-core/public/services/state/types.ts +++ b/plugins/wazuh-core/public/services/state/types.ts @@ -27,6 +27,7 @@ export interface State< get: (name: string) => any; set: (name: string, value: any) => any; remove: (name: string) => any; + getStateContainer: (name: string) => StateContainer | undefined; register: (name: string, value: StateContainer) => any; subscribe: ( name: string,