# Function watchEvent

- watchEvent<TObsv, TPath, TTarget>(obj, path, event, watchCallback?): IHandle

- Watches the given path on the given object for changes and automatically adds and removes the given event listener.

  #### Type Parameters

  - TObsv extends Observable
  - TPath extends string
  - TTarget

  #### Parameters

  - obj: TObsv

    The object to watch.

  - path: TPath

    The property path to an Evented object on the given object to watch.

  - event: Parameters<Exclude<OverloadUnionRecursive<(() => never) & NonNullable<TTarget>["on"], unknown>, NonNullable<TTarget>["on"] extends (() => never)
    ? never
    : (() => never)>>

    The event and the listener to add to the Evented object.

  - `Optional` watchCallback: ((newTarget: TTarget, oldTarget: TTarget) => void)

    The callback to invoke when the watched property changes. This is optional and will be invoked with the Evented object being watched.

    - - (newTarget, oldTarget): void

      - #### Parameters

        - newTarget: TTarget
        - oldTarget: TTarget

        #### Returns void

  #### Returns IHandle

  #### Throws

  Error if the object is not observable.

  #### Throws

  Error if the path is to a non-configurable property on an observable.