Skip to content

2.1.0

Compare
Choose a tag to compare
@jan-tennert jan-tennert released this 30 Jan 12:56
· 918 commits to master since this release
3d9502d

Notes

The documentation has been updated accordingly.
It might take a bit to appear on Maven Central, as publishing seems to be broken right now

Changes

Add iOS targets to the chat-demo by @hieuwu in #397

Realtime

  • Add an option (Realtime.Config#disconnectOnNoSubscriptions) to automatically disconnect from the websocket, once there is no channel left, which defaults to true. (in #416 by @jan-tennert)
  • Remove the error for Realtime when a channel is already connected by @jollygreenegiant in #430
  • Provide a new (experimental) way to listen to Realtime data (built on top of the existing ones) (in #386 by @jan-tennert):

Note: For both methods, the flows automatically emit the initial data and then listen for events using the existing methods.
Listen for changes in all messages (handles inserts, updates and deletes automatically and emits the updated list)

val messageFlow: Flow<List<Message>> = channel.postgresListDataFlow<Message>( //provide your serializable type (in this case Message)
    table = "messages",
    filter = FilterOperation("id", FilterOperator.IN, listOf(1, 2, 3, 4)), //optional filter
    primaryKey = Message::id //provide the primary key for caching
)

Listen for changes on a single value

val singleMessageFlow: Flow<Message> = channel.postgresSingleDataFlow<Message>( //Automatically emits the updated message and closes on delete
    table = "messages",
    primaryKey = Message::id
) { //this is the same filter builder the Postgrest plugin uses, so you can use everything:
    Message::id eq 2
    or {
        Message::creatorId isIn listOf("1", "2", "3")
        Message::content like "%test%"
    }
}

Listen to presence changes (joins & leaves are handled automatically)

val presenceFlow: Flow<List<User>> = channel.presenceDataFlow<User>()
  • Add a new method for adding a filter to postgres changes:
supabase.channel("channel").postgresChangeFlow<PostgresAction>("public") {
    //Still only one filter supported
    filter("id", FilterOperator.EQ, 2)
    //Note that some values get converted to strings e.g. the List<Int> to (1,2,3)
    filter("id", FilterOperator.IN, listOf(1, 2, 3, 4))
}

New methods:

  • RealtimeChannel#postgresSingleDataFlow
  • RealtimeChannel#postgresListDataFlow
  • RealtimeChannel#presenceDataFlow
  • RealtimeChannelBuilder#filter

GoTrue

Compose Auth

Postgrest