-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(query): allow invalidating of all cache (#2053)
- Loading branch information
Showing
4 changed files
with
89 additions
and
6 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,29 @@ | ||
--- | ||
"@equinor/fusion-query": minor | ||
--- | ||
|
||
`QueryCache` now supports invalidation of all entries | ||
|
||
When not providing key for `QueryCache.invalidate`, all records will be set to invalid | ||
|
||
```diff | ||
QueryCache.ts | ||
- public invalidate(key: string) { | ||
+ public invalidate(key?: string) { | ||
this.#state.next(actions.invalidate(key)); | ||
} | ||
``` | ||
|
||
```diff | ||
create-reducer.ts | ||
.addCase(actions.invalidate, (state, action) => { | ||
+ const invalidKey = action.payload ? [action.payload] : Object.keys(state); | ||
- const entry = state[action.payload]; | ||
+ for (const key of invalidKey) { | ||
+ const entry = state[key]; | ||
if (entry) { | ||
delete entry.updated; | ||
} | ||
+ } | ||
}) | ||
``` |
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
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
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