From caf63273eff7a95ca0e69f0940340f01cb9de9f5 Mon Sep 17 00:00:00 2001 From: Sriram Hariharan Date: Tue, 23 Apr 2024 23:53:45 -0500 Subject: [PATCH] updated use hook to now allow pulling in the entire object --- package.json | 2 +- src/storage/createStore.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9d25fa8..25d5328 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chrome-extension-toolkit", - "version": "0.0.66", + "version": "0.0.67", "description": "A template for creating npm packages using TypeScript and VSCode", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/storage/createStore.ts b/src/storage/createStore.ts index 6a322ff..0c49ab8 100644 --- a/src/storage/createStore.ts +++ b/src/storage/createStore.ts @@ -83,7 +83,7 @@ export type Store = { /** * A react hook that allows you to get and set the value of the specified key in the store from a functional component. - * @param key the key to get the value of + * @param key the key to get the value of or null to get the entire store * @returns a tuple containing the value of the specified key, and a function to set the value */ use : T>( @@ -92,7 +92,7 @@ export type Store = { /** * A react hook that allows you to get and set the value of the specified key in the store from a functional component. - * @param key the key to get the value of + * @param key the key to get the value of or null to get the entire store * @param defaultValue the default value to use if the key is not already set */ use( @@ -320,6 +320,7 @@ function createStore( const onChanged = (change: DataChange) => { const newValue: any = { ...value }; newValue[change.key] = change.newValue; + setValue(newValue); }; // @ts-ignore Object.keys(defaults).forEach(k => store.subscribe(k, onChanged));