Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/computedAsync/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Fn } from '@vueuse/shared'
import type { Fn, WatchOptionFlush } from '@vueuse/shared'
import type { ComputedRef, Ref } from 'vue'
import { noop } from '@vueuse/shared'
import {
Expand Down Expand Up @@ -44,7 +44,7 @@ export interface AsyncComputedOptions<Lazy = boolean> {
* It works in the same way as the flush option in watch and watch effect in vue reactivity
* @default 'pre'
*/
flush?: 'pre' | 'post' | 'sync'
flush?: WatchOptionFlush

/**
* Callback when error is caught.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useRefHistory/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const refHistory = useRefHistory(target, {
refHistory.clear() // explicitly clear all the history
```

### History Flush Timing
### History WatchOptionFlush Timing

From [Vue's documentation](https://vuejs.org/guide/essentials/watchers.html#callback-flush-timing): Vue's reactivity system buffers invalidated effects and flush them asynchronously to avoid unnecessary duplicate invocation when there are many state mutations happening in the same "tick".

Expand Down
4 changes: 2 additions & 2 deletions packages/core/useRefHistory/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ConfigurableEventFilter, Fn } from '@vueuse/shared'
import type { ConfigurableEventFilter, Fn, WatchOptionFlush } from '@vueuse/shared'
import type { Ref } from 'vue'
import type { CloneFn } from '../useCloned'
import type { UseManualRefHistoryReturn } from '../useManualRefHistory'
Expand All @@ -23,7 +23,7 @@ export interface UseRefHistoryOptions<Raw, Serialized = Raw> extends Configurabl
*
* @default 'pre'
*/
flush?: 'pre' | 'post' | 'sync'
flush?: WatchOptionFlush

/**
* Maximum number of history to be kept. Default to unlimited.
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/syncRefs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface SyncRefOptions {
*
* @default 'sync'
*/
flush?: WatchOptions['flush']
flush?: WatchOptionFlush
/**
* Watch deeply
*
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/until/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MaybeRefOrGetter, WatchOptions, WatchSource } from 'vue'
import type { ElementOf, ShallowUnwrapRef } from '../utils'
import type { ElementOf, ShallowUnwrapRef, WatchOptionFlush } from '../utils'
import { isRef, nextTick, toValue, watch } from 'vue'
import { promiseTimeout } from '../utils'

Expand All @@ -24,7 +24,7 @@ export interface UntilToMatchOptions {
*
* @default 'sync'
*/
flush?: WatchOptions['flush']
flush?: WatchOptionFlush

/**
* `deep` option for internal watch
Expand Down
6 changes: 4 additions & 2 deletions packages/shared/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ export interface Stoppable<StartFnArgs extends any[] = any[]> {
start: (...args: StartFnArgs) => void
}

export type WatchOptionFlush = WatchOptions['flush']

export interface ConfigurableFlush {
/**
* Timing for monitoring changes, refer to WatchOptions for more details
*
* @default 'pre'
*/
flush?: WatchOptions['flush']
flush?: WatchOptionFlush
}

export interface ConfigurableFlushSync {
Expand All @@ -127,7 +129,7 @@ export interface ConfigurableFlushSync {
*
* @default 'sync'
*/
flush?: WatchOptions['flush']
flush?: WatchOptionFlush
}

// Internal Types
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/watchIgnorable/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ source.value = 'logged'
await nextTick() // logs: Changed to logged!
```

## Flush timing
## WatchOptionFlush timing

`watchIgnorable` accepts the same options as `watch` and uses the same defaults.
So, by default the composable works using `flush: 'pre'`.
Expand Down