suspend fun getStream(gameId: String?): Flow<StreamSupabase> {
val channel = createChannel(gameId)
val channelFilter ="is_featured=eq.true"
val changeFlow = channel.postgresChangeFlow<PostgresAction>("public") {
table = "Stream"
filter = channelFilter
}.map {
when (it) {
is PostgresAction.Delete -> error("Delete should not be possible")
is PostgresAction.Insert -> it.decodeRecord<StreamDto>().mapToEntity()
is PostgresAction.Select -> error("Select should not be possible")
is PostgresAction.Update -> it.decodeRecord<StreamDto>().mapToEntity()
}
}.catch {
Log.d("StreamDatasource", "getFeaturedStream Error: $it")
}
channel.subscribe()
return changeFlow
}
suspend fun getStream(gameId: String?): Flow<StreamSupabase> {
val channel = createChannel(gameId)
val channelFilter ="is_featured=eq.true"
val changeFlow = channel.postgresChangeFlow<PostgresAction>("public") {
table = "Stream"
filter = channelFilter
}.map {
when (it) {
is PostgresAction.Delete -> error("Delete should not be possible")
is PostgresAction.Insert -> it.decodeRecord<StreamDto>().mapToEntity()
is PostgresAction.Select -> error("Select should not be possible")
is PostgresAction.Update -> it.decodeRecord<StreamDto>().mapToEntity()
}
}.catch {
Log.d("StreamDatasource", "getFeaturedStream Error: $it")
}
channel.subscribe()
return changeFlow
}