Supabase Realtime Subscription Service
Component Detail
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.
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)