@umbraco-cms/backoffice
    Preparing search index...

    Class UmbEntityReferenceCountManager

    Tracks the total number of items referencing a given entity, so a consumer (e.g. a publishing workspace context) can make a decision that depends on the count (like whether to show a confirmation dialog) without awaiting a network round-trip at the point of decision.

    UmbEntityReferenceCountManager

    Hierarchy (View Summary)

    Index
    total: Observable<number | undefined> = ...

    Observable emitting the current reference count. undefined until the first successful load.

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • Get the current reference count, loading it first if it hasn't loaded yet. Use this at decision points (e.g. "should a confirmation dialog open?") so an unlucky race with the initial load can't silently read as 0. Piggybacks on a reload already in flight (e.g. from setUnique) rather than starting a second, redundant one — starting a second one here would race the first and could win with a stale/empty result.

      Returns Promise<number>

      The reference count.

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • Set the entity to count references for. A no-op if the unique is unchanged. When prefetch is enabled (the default), also (re)loads the count immediately; otherwise the count is loaded lazily, on the first getTotalAsync call.

      Parameters

      • unique: string | undefined

        The unique identifier of the entity, or undefined to clear.

      Returns Promise<void>