-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(nuxt): deep watch useCookie
ref value by default
#9664
Conversation
Β Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
@xtoolkit is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
Sorry for my bad English. please rewrite document ... |
@@ -15,6 +15,7 @@ export interface CookieOptions<T = any> extends _CookieOptions { | |||
decode?(value: string): T | |||
encode?(value: T): string | |||
default?: () => T | Ref<T> | |||
watch?: boolean | 'deep' | 'shallow' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
watch?: boolean | 'deep' | 'shallow' | |
watch?: false | 'deep' | 'shallow' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think better keep boolean
type. Because it maybe passed by variable.
export function useCookieTest(watch: boolean) {
const test = useCookie('test', {}, {watch})
const change = () => {test.value = 100}
return {change}
}
|
||
Specifies the `boolean` or `string` value for [watch](https://vuejs.org/api/reactivity-core.html#watch) cookie ref data. | ||
|
||
- `true` or `shallow` will watch cookie ref data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `true` or `shallow` will watch cookie ref data. | |
- `shallow` will watch cookie ref data. |
@danielroe Do you agree to making default behavior deep watching cookie value or any merits to keep it one level by default? |
Agreed - I think deep behaviour is more intuitive. π |
useCookie
ref value by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM β€οΈ
* feat(nuxt): useCookie add deep watch option * docs(api): useCookie add deepWatch option * feat(nuxt): useCookie change deepWatch to watch option * boolean|shallow * enable watch by default * docs: fix example * docs(api): update useCookie example Co-authored-by: Pooya Parsa <pooya@pi0.io> Co-authored-by: Daniel Roe <daniel@roe.dev>
π Linked issue
β Type of change
π Description
useCookie
only change when.value
update. we can use deep flag in watch and track all change.π Checklist