Skip to main content

useObjectSubscription

Auto-managed live-update subscription for a single OpenRegister object (or a collection). Wraps objectStore.subscribe(type, id?) from liveUpdatesPlugin with a Vue scope-bound lifecycle: subscribes on mount, releases on unmount, re-subscribes when reactive inputs change.

Signature

import { useObjectSubscription } from '@conduction/nextcloud-vue'

const { status, lastEventAt } = useObjectSubscription(objectStore, type, id, options)

Arguments

NameTypeDescription
objectStoreobjectPinia store instance (typically useObjectStore()).
typestring | Ref<string>Object type slug.
idstring | Ref<string> | nullObject UUID for per-object subscription, or null for the collection.
options.enabledboolean | Ref<boolean>Reactive gate; subscribe only when truthy. Default true.

Returns

FieldTypeDescription
statusRef<'connecting' | 'open' | 'closed'>Subscription state.
lastEventAtRef<Date | null>Timestamp of the most recent event seen by the underlying plugin.

Notes

  • Used by default inside CnDetailPage and CnObjectSidebar. Set subscribe: false on those components to opt out.
  • The composable does not refetch on its own; the liveUpdatesPlugin already invalidates the store cache on each or-object-{uuid} event, which triggers a refetch and a reactive re-render in any consumer reading from objectStore.objects[type][id].
  • See OpenRegister push events docs for the wire format.