Remove Starscream Dependency and bump minimum support platform (#11) Remove Starscream Bump swift-tools-version to 5.5
Remove Starscream Dependency and bump minimum support platform (#11)
Remove Starscream
Bump swift-tools-version to 5.5
realtime-swift
Listens to changes in a PostgreSQL Database and via websockets.
A Swift client for Supabase Realtime server.
You can set up one connection to be used across the whole app.
import Realtime var client = RealtimeClient(endPoint: "https://yourcompany.supabase.co/realtime/v1", params: ["apikey": "public-anon-key"]) client.connect()
Socket Hooks
client.onOpen { print("Socket opened.") } client.onError { error in print("Socket error: ", error.localizedDescription) } client.onClose { print("Socket closed") }
Disconnect the socket
Call disconnect() on the socket:
disconnect()
client.disconnect()
You can subscribe to all topic, or to specific schema parts.
let allChanges = client.channel(.all) allChanges.on(.all) { message in print(message) } allChanges.subscribe() // ... allChanges.unsubscribe() allChanges.off(.all)
let allPublicInsertChanges = client.channel(.schema("public")) allPublicInsertChanges.on(.insert) { message in print(message) } allPublicInsertChanges.subscribe() // ... allPublicInsertChanges.unsubscribe() allPublicInsertChanges.off(.insert)
let allUsersUpdateChanges = client.channel(.table("users", schema: "public")) allUsersUpdateChanges.on(.update) { message in print(message) } allUsersUpdateChanges.subscribe() // ... allUsersUpdateChanges.unsubscribe() allUsersUpdateChanges.off(.update)
let allUserId99Changes = client.channel(.column("id", value: "99", table: "users", schema: "public")) allUserId99Changes.on(.all){ message in print(message) } allUserId99Changes.subscribe() // ... allUserId99Changes.unsubscribe() allUserId99Changes.off(.all)
This repo is licensed under MIT.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
realtime-swift
Listens to changes in a PostgreSQL Database and via websockets.
A Swift client for Supabase Realtime server.
Usage
Creating a Socket connection
You can set up one connection to be used across the whole app.
Socket Hooks
Disconnect the socket
Call
disconnect()
on the socket:Subscribe to topics
You can subscribe to all topic, or to specific schema parts.
Credits
License
This repo is licensed under MIT.