Skip to content

⬅️ Back to Table of Contents

📄 refManualReset

📊 Analysis Summary

Metric Count
🔧 Functions 2
📦 Imports 5
📐 Interfaces 1

📚 Table of Contents

🛠️ File Location:

📂 packages/shared/refManualReset/index.ts

📦 Imports

Name Source
MaybeRefOrGetter vue
Ref vue
Fn ../utils
customRef vue
toValue vue

Functions

refManualReset(defaultValue: MaybeRefOrGetter<T>): ManualResetRefReturn<T>

Create a ref with manual reset functionality.

Parameters:

  • defaultValue any: The value which will be set.

See: https://vueuse.org/refManualReset

Raw JSDoc
/**
 * Create a ref with manual reset functionality.
 *
 * @see https://vueuse.org/refManualReset
 * @param defaultValue The value which will be set.
 */

Calls:

  • toValue (from vue)
  • trigger
  • customRef (from vue)
  • track
Code
export function refManualReset<T>(defaultValue: MaybeRefOrGetter<T>): ManualResetRefReturn<T> {
  let value: T = toValue(defaultValue)
  let trigger: Fn

  const reset = () => {
    value = toValue(defaultValue)
    trigger()
  }

  const refValue = customRef<T>((track, _trigger) => {
    trigger = _trigger
    return {
      get() {
        track()
        return value
      },
      set(newValue) {
        value = newValue
        trigger()
      },
    }
  }) as ManualResetRefReturn<T>

  refValue.reset = reset

  return refValue
}

Internal helpers

Declared inside another function in this file.

reset(): void

Returns: void

Calls:

  • toValue (from vue)
  • trigger
Code
() => {
    value = toValue(defaultValue)
    trigger()
  }

Interfaces

ManualResetRefReturn<T>

Interface Code
export interface ManualResetRefReturn<T> extends Ref<T> {
  reset: Fn
}

Properties

Name Type Optional Description
reset Fn not shown

Generated by Syntax Scribe