Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Add ability to supply an array of ids
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Jul 3, 2019
1 parent 4eac701 commit 4251a29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,12 @@ Unique identifier for the promise (`load`). Enables the ability to [persist the

##### id

> `string` | Used only with [resources](#resources-apiresource--createresourceoptions)
> `string | Array<string>` | Used only with [resources](#resources-apiresource--createresourceoptions)
A unique ID to associate with a resource. This ID is used in conjunction with the resource's namespace to set and retrieve the value from the cache.

You can provide a unique string, or an array of unique strings.

##### args

> `Array<any>` | Used only with [resources](#resources-apiresource--createresourceoptions)
Expand Down
3 changes: 2 additions & 1 deletion src/useLoads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default function useLoads<R>(fn: LoadFunction<R>, config: LoadsConfig<R>
timeout = 0,
update: updateFn
} = config;
const contextKey = config.id ? `${config.context}.${config.id}` : config.context;
const id = Array.isArray(config.id) ? config.id.join('.') : config.id;
const contextKey = config.id ? `${config.context}.${id}` : config.context;

const globalContext = React.useContext(LoadsContext);
const counter = React.useRef<number>(0);
Expand Down

0 comments on commit 4251a29

Please sign in to comment.