Skip to content

⬅️ Back to Table of Contents

📄 index.ts

📊 Analysis Summary

Metric Count
🔧 Functions 2
📦 Imports 9
📊 Variables & Constants 6
🟢 Vue Composition API 1
📐 Interfaces 3
📑 Type Aliases 1

📚 Table of Contents

🛠️ File Location:

📂 packages/shared/computedWithControl/index.ts

📦 Imports

Name Source
ComputedGetter vue
ComputedRef vue
WatchSource vue
WritableComputedOptions vue
WritableComputedRef vue
Fn ../utils
customRef vue
shallowRef vue
watch vue

Variables & Constants

Name Type Kind Value Exported
v T let/var undefined!
track Fn let/var *not shown*
trigger Fn let/var *not shown*
get any const typeof fn === 'function' ? fn : fn.get
set any const typeof fn === 'function' ? undefined : fn.set
result ComputedRefWithControl<T> const `customRef((_track, _trigger) => {
track = _track
trigger = _trigger
return {
  get() {
    if (dirty.value) {
      v = get(v)
      dirty.value = false
    }
    track()
    return v
  },
  set(v) {
    set?.(v)
  },
}

}) as ComputedRefWithControl` | ✗ |


Vue Composition API

Name Type Reactive Variables Composables
watch watch none none

Functions

computedWithControl(source: WatchSource<S> | WatchSource<S>[], fn: ComputedGetter<T>): ComputedRefWithControl<T>

Code
export function computedWithControl<T, S>(
  source: WatchSource<S> | WatchSource<S>[],
  fn: ComputedGetter<T>
): ComputedRefWithControl<T>
  • Parameters:
  • source: WatchSource<S> | WatchSource<S>[]
  • fn: ComputedGetter<T>
  • Return Type: ComputedRefWithControl<T>

update(): void

Code
() => {
    dirty.value = true
    trigger()
  }
  • Return Type: void
  • Calls:
  • trigger

Interfaces

ComputedWithControlRefExtra

Interface Code
export interface ComputedWithControlRefExtra {
  /**
   * Force update the computed value.
   */
  trigger: () => void
}

Properties

Name Type Optional Description
trigger () => void

ComputedRefWithControl<T>

Interface Code
export interface ComputedRefWithControl<T> extends ComputedRef<T>, ComputedWithControlRefExtra {}

WritableComputedRefWithControl<T>

Interface Code
export interface WritableComputedRefWithControl<T> extends WritableComputedRef<T>, ComputedWithControlRefExtra {}

Type Aliases

ComputedWithControlRef<T = any = any>

type ComputedWithControlRef<T = any = any> = ComputedRefWithControl<T> | WritableComputedRefWithControl<T>;