once<T> method

Watcher<T> once<T>(
  1. SourcesFn<T> sourcesFn,
  2. WatcherFn<T> fn, {
  3. WhenFn<T>? when,
  4. JoltDebugFn? onDebug,
})

Creates a watcher hook that executes only once.

Parameters:

  • sourcesFn: Function that returns the values to watch
  • fn: Callback function executed when sources change
  • when: Optional condition function for custom trigger logic
  • onDebug: Optional debug callback for reactive system debugging

Returns: A Watcher that executes only once

Implementation

Watcher<T> once<T>(
  SourcesFn<T> sourcesFn,
  WatcherFn<T> fn, {
  WhenFn<T>? when,
  JoltDebugFn? onDebug,
}) {
  return useAutoDispose(
      () => Watcher<T>.once(sourcesFn, fn, when: when, onDebug: onDebug));
}