Skip to content

refThrottled fix: 🧩 fixed reference issues for complex data types #3705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Prev Previous commit
refactor: ♻️ refactor
  • Loading branch information
17359898647 committed Jan 11, 2024
commit 0edfcbacd485dfaf10b5a245815f1c066b488c4d
10 changes: 4 additions & 6 deletions packages/shared/refThrottled/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,21 @@ export function refThrottled<T>(value: Ref<T>, delay?: number, trailing?: boolea
export function refThrottled<T>(options: RefThrottledOptions<T>): Ref<T>
export function refThrottled<T>(...args: any[]): Ref<T> {
const isFirstRef = isRef(args[0])
const value = isFirstRef ? args[0] : args[0].value
// const [delay = 200, trailing = true, leading = true, deep = true, immediate = true, cloneHandler = cloneFnJSON] = isFirstRef ? args.slice(1) : args[0]
let value: Ref<T>
let delay: number
let trailing: boolean
let leading: boolean
let deep: boolean
let immediate: boolean
let cloneHandler: (value: T) => T
if (isFirstRef)
[delay = 200, trailing = true, leading = true, deep = true, immediate = true, cloneHandler = cloneFnJSON] = args.slice(1)
[value, delay = 200, trailing = true, leading = true, deep = true, immediate = true, cloneHandler = cloneFnJSON] = args
else
({ delay = 200, trailing = true, leading = true, deep = true, immediate = true, cloneHandler = cloneFnJSON } = args[0])

({ value, delay = 200, trailing = true, leading = true, deep = true, immediate = true, cloneHandler = cloneFnJSON } = args[0])
if (delay <= 0)
return value
const isEqualityClone = cloneHandler === cloneFnJSON
const { sync, cloned: throttled } = useCloned(
const { sync, cloned: throttled } = useCloned<T>(
value,
{
manual: true,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy