forked from reactplay/react-play
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cached data internally in order to prevent multiple api calls on each…
… filter modal mount (reactplay#875) * cached data internally in order to prevent multiple api calls on each filter modal mount * eslint fix Co-authored-by: Tapas Adhikary <[email protected]>
- Loading branch information
1 parent
d415477
commit d030232
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
interface TcacheObject { | ||
[key: string]: any; | ||
} | ||
|
||
type TReturn = [(s: string) => any, (t: string, c: any) => void]; | ||
|
||
const cacheObject: TcacheObject = new Object(); | ||
|
||
const useCacheResponse = (): TReturn => { | ||
const createCache = (cacheName: string, cacheData: any): any => { | ||
cacheObject[cacheName] = cacheData; | ||
}; | ||
|
||
const retrieveCache = (cacheName: string): any => { | ||
return cacheObject[cacheName] ? cacheObject[cacheName] : null; | ||
}; | ||
|
||
return [retrieveCache, createCache]; | ||
}; | ||
|
||
export default useCacheResponse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters