β¬ οΈ Back to Table of Contents
π usePerformanceObserver¶
π Analysis Summary¶
| Metric | Count |
|---|---|
| π§ Functions | 3 |
| π¦ Imports | 4 |
| π Type Aliases | 1 |
π Table of Contents¶
π οΈ File Location:¶
π packages/core/usePerformanceObserver/index.ts
π¦ Imports¶
| Name | Source |
|---|---|
ConfigurableWindow |
../_configurable |
tryOnScopeDispose |
@vueuse/shared |
defaultWindow |
../_configurable |
useSupported |
../useSupported |
Functions¶
usePerformanceObserver(options: UsePerformanceObserverOptions, callback: PerformanceObserverCallback): { isSupported: ComputedRef<boolean>; start: () => void; sto⦶
Observe performance metrics.
Parameters:
optionsany: No description
See: https://vueuse.org/usePerformanceObserver
Raw JSDoc
Calls:
useSupported (from ../useSupported)observer?.disconnectstopobserver.observetryOnScopeDispose (from @vueuse/shared)start
Code
export function usePerformanceObserver(options: UsePerformanceObserverOptions, callback: PerformanceObserverCallback) {
const {
window = defaultWindow,
immediate = true,
...performanceOptions
} = options
const isSupported = useSupported(() => window && 'PerformanceObserver' in window)
let observer: PerformanceObserver | undefined
const stop = () => {
observer?.disconnect()
}
const start = () => {
if (isSupported.value) {
stop()
observer = new PerformanceObserver(callback)
observer.observe(performanceOptions)
}
}
tryOnScopeDispose(stop)
if (immediate)
start()
return {
isSupported,
start,
stop,
}
}
Internal helpers¶
Declared inside another function in this file.
stop(): void¶
Returns: void
Calls:
observer?.disconnect
start(): void¶
Returns: void
Calls:
stopobserver.observe
Code
Type Aliases¶
UsePerformanceObserverOptions¶
type UsePerformanceObserverOptions = PerformanceObserverInit & ConfigurableWindow & {
/**
* Start the observer immediate.
*
* @default true
*/
immediate?: boolean
};
Generated by Syntax Scribe