Infrastructure medium complexity Shared Component mobile
0
Dependencies
1
Dependents
1
Entities
1
Integrations

Description

Manages Supabase Realtime channel subscriptions for the notifications table, scoped to the current user's user_id. Emits a stream of notification change events (INSERT, UPDATE, DELETE) that the BLoC consumes. Handles reconnection on connectivity loss and cleans up subscriptions on dispose to prevent memory leaks.

Feature: In-app Notification Centre

supabase-realtime-subscription-service

Responsibilities

  • Create and manage Supabase Realtime channel for notifications table
  • Scope subscription to current user's user_id filter
  • Emit typed notification events from raw Realtime payloads
  • Handle channel reconnection on network interruption
  • Dispose channel subscription on widget unmount or logout

Interfaces

subscribe(String userId): Stream<NotificationChangeEvent>
unsubscribe()
isConnected(): bool
reconnect()
onInsert(Map<String, dynamic> record)
onUpdate(Map<String, dynamic> record)
onDelete(String notificationId)

Relationships

Dependents (1)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component

Used Integrations (1)

External integrations and APIs this component relies on

API Contract

View full contract →
REST /api/v1/notification-subscriptions 5 endpoints
GET /api/v1/notification-subscriptions List all active realtime subscriptions
GET /api/v1/notification-subscriptions/:id Get status and details of a specific subscription
POST /api/v1/notification-subscriptions Create a new realtime subscription for a user
PUT /api/v1/notification-subscriptions/:id Update subscription state (e.g. trigger reconnect or pause)
DELETE /api/v1/notification-subscriptions/:id Unsubscribe and remove a realtime subscription