• Listens to change events on a collection property. This function also handles the case where the collection property itself is changed, in addition to items being added or removed to the collection. If the collection property is changed, it will automatically start watching the new collection if there is one and stop watching the old. In this case it will calculate the difference between the two collections and emit a "change" event with the appropriate values for event.added, event.removed, etc.

    Because this function calculates the difference between property changes it is best to avoid using this function if you are only interested in the collection changed event occurring and not the items that were added or removed. In that case, use support/observableUtils!watchEvent instead.

    Type Parameters

    • T

    Parameters

    • obj: Observable

      The object that owns the collection property to watch.

    • path: string

      The collection property to watch.

    • callback: EventedCallback<CollectionChangeEvent<T>>

      The callback to invoke when the collection changes.

    • sync: boolean = false

      Whether to invoke the callback synchronously. The default is false.

    Returns IHandle