Skip to content

Commit

Permalink
updated use hook to now allow pulling in the entire object
Browse files Browse the repository at this point in the history
  • Loading branch information
sghsri committed Apr 24, 2024
1 parent c5c46cc commit a216357
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chrome-extension-toolkit",
"version": "0.0.68",
"version": "0.0.69`",
"description": "A template for creating npm packages using TypeScript and VSCode",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
9 changes: 6 additions & 3 deletions src/storage/createStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ export type Store<T = {}> = {
* @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<K extends keyof T | null, D extends K extends keyof T ? Serializable<T[K]> : T>(
use<K extends keyof T | null>(
key: K
): [D, (value: D) => Promise<void>];
): [
K extends keyof T ? Serializable<T[K]> : T,
(value: K extends keyof T ? Serializable<T[K]> : Partial<Serializable<T>>) => Promise<void>
];

/**
* A react hook that allows you to get and set the value of the specified key in the store from a functional component.
Expand All @@ -100,7 +103,7 @@ export type Store<T = {}> = {
defaultValue: K extends keyof T ? Serializable<T[K]> : T
): [
K extends keyof T ? Serializable<T[K]> : T,
(value: K extends keyof T ? Serializable<T[K]> : T) => Promise<void>
(value: K extends keyof T ? Serializable<T[K]> : Partial<Serializable<T>>) => Promise<void>
];

/**
Expand Down

0 comments on commit a216357

Please sign in to comment.