Realtime
Plugin for interacting with the supabase realtime api
To use it you need to install it to the SupabaseClient:
val supabase = createSupabaseClient(supabaseUrl, supabaseKey) {
install(Realtime)
}
Content copied to clipboard
You can then create a channel:
val channel = supabase.realtime.channel("channelId")
Content copied to clipboard
Then listen to events on the channel:
val productChangeFlow = channel.postgrestChangeFlow<PostgrestAction.Insert>(schema = "public") {
table = "products"
}.map { it.decodeRecord<Product>() }
Content copied to clipboard
And at last you have to subscribe to the channel:
channel.subscribe()
Content copied to clipboard
Types
Link copied to clipboard
Link copied to clipboard
data class Config(var websocketConfig: WebSockets.Config.() -> Unit = {}, var secure: Boolean? = null, var heartbeatInterval: Duration = 15.seconds, var reconnectDelay: Duration = 7.seconds, var disconnectOnSessionLoss: Boolean = true, var connectOnSubscribe: Boolean = true, var websocketFactory: RealtimeWebsocketFactory? = null, var disconnectOnNoSubscriptions: Boolean = true) : MainConfig, CustomSerializationConfig
Link copied to clipboard
The current status of the realtime connection
Properties
Functions
Link copied to clipboard
Link copied to clipboard
inline fun Realtime.channel(channelId: String, builder: RealtimeChannelBuilder.() -> Unit = {}): RealtimeChannel
Creates a new RealtimeChannel
Link copied to clipboard
Connects to the realtime websocket. The url will be taken from the custom provided Realtime.Config.customUrl or SupabaseClient
Link copied to clipboard
Disconnects from the realtime websocket
Link copied to clipboard
Link copied to clipboard
Unsubscribes and removes all channels from the subscriptions
Link copied to clipboard
Unsubscribes and removes a channel from the subscriptions
Link copied to clipboard
Link copied to clipboard
Sends a message to the realtime websocket