Skip to content

Commit

Permalink
feat(useAsyncState): add option for choosing shallowRef or ref (vites…
Browse files Browse the repository at this point in the history
  • Loading branch information
darkxanter committed Dec 12, 2021
1 parent 169b02b commit b995216
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/core/useAsyncState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ export interface AsyncStateOptions {
* @default true
*/
resetOnExecute?: boolean

/**
* Use shallowRef.
*
* @default true
*/
shallow?: boolean
}

/**
Expand All @@ -62,9 +69,10 @@ export function useAsyncState<T>(
delay = 0,
onError = noop,
resetOnExecute = true,
shallow = true,
} = options

const state = shallowRef(initialState)
const state = shallow ? shallowRef(initialState) : ref(initialState) as Ref<T>
const isReady = ref(false)
const error = ref<unknown | undefined>(undefined)

Expand Down

0 comments on commit b995216

Please sign in to comment.