-
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.
feat(wrap): add withDomainDrivenGets cache wrapper
- Loading branch information
1 parent
6a1d854
commit d5e09ea
Showing
8 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export { ref } from './logic/ref/ref'; | ||
export { withMutationEffects } from './logic/withMutationEffects'; | ||
export { withQueryCaching } from './logic/withQueryCaching'; | ||
export { withDomainDrivenGets } from './logic/withDomainDrivenGets'; | ||
export * from './domain/DomainDrivenQueryDependency'; | ||
export * from './domain/DomainDrivenQueryDependsOn'; |
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,23 @@ | ||
import { withoutSet } from 'simple-lambda-client'; | ||
import { | ||
withDenormalization, | ||
withSerialization, | ||
} from 'with-cache-normalization'; | ||
import { SerializableObject } from 'with-cache-normalization/dist/domain/NormalizeCacheValueMethod'; | ||
import { SimpleCache } from 'with-simple-caching'; | ||
|
||
/** | ||
* a method which makes it easy to get from a domain-driven cache, without access to the query logic itself | ||
* | ||
* specifically | ||
* - adds withoutSet to the cache, since only the withQueryCaching wrapped method should be calling that | ||
* - adds withSerialization to the cache, to make it compatible with normalization | ||
* - adds withDenormalization to the cache, to enable it to denormalize the normalized cached query outputs | ||
* | ||
* usecase | ||
* - accessing outputs .set by a lambda server, at the lambda client (e.g., with [simple-lambda-client](https://github.com/ehmpathy/simple-lambda-client)) | ||
*/ | ||
export const withDomainDrivenGets = ( | ||
cache: SimpleCache<string>, | ||
): SimpleCache<SerializableObject> => | ||
withoutSet(withDenormalization(withSerialization<SerializableObject>(cache))); |