Skip to content

Commit

Permalink
fix(types): update createHooks to handle optional updater$ for better…
Browse files Browse the repository at this point in the history
… robustness in state management functionality
  • Loading branch information
guidomodarelli committed Dec 12, 2024
1 parent 1f1caa9 commit 7a2c1f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/wazuh-core/public/services/state/hooks/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { State } from '../types';
export const createHooks = ({ state }: { state: State }) => {
function useStateContainer<T>(name: string) {
const value: T = useObservable(
state.getStateContainer(name).updater$,
state.getStateContainer(name)?.updater$,
state.get(name),
);

Expand Down
1 change: 1 addition & 0 deletions plugins/wazuh-core/public/services/state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7a2c1f2

Please sign in to comment.