This repository was archived by the owner on Apr 6, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
docs/content/3.api/3.utils
packages/nuxt/src/app/composables Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ This method is useful if you want to invalidate the data fetching for another pa
10
10
## Type
11
11
12
12
``` ts
13
- clearNuxtData (keys ?: string | string []): void
13
+ clearNuxtData (keys ?: string | string [] | (( key : string ) => boolean ) ): void
14
14
```
15
15
16
16
## Parameters
Original file line number Diff line number Diff line change @@ -254,9 +254,14 @@ export function refreshNuxtData (keys?: string | string[]): Promise<void> {
254
254
return useNuxtApp ( ) . callHook ( 'app:data:refresh' , _keys )
255
255
}
256
256
257
- export function clearNuxtData ( keys ?: string | string [ ] ) : void {
257
+ export function clearNuxtData ( keys ?: string | string [ ] | ( ( key : string ) => boolean ) ) : void {
258
258
const nuxtApp = useNuxtApp ( )
259
- const _keys = keys ? Array . from ( keys ) . filter ( key => key && typeof key === 'string' ) : Object . keys ( nuxtApp . payload . data )
259
+ const _allKeys = Object . keys ( nuxtApp . payload . data )
260
+ const _keys : string [ ] = ! keys
261
+ ? _allKeys
262
+ : typeof keys === 'function'
263
+ ? _allKeys . filter ( keys )
264
+ : Array . isArray ( keys ) ? keys : [ keys ]
260
265
261
266
for ( const key of _keys ) {
262
267
if ( key in nuxtApp . payload . data ) {
You can’t perform that action at this time.
0 commit comments