-
-
Notifications
You must be signed in to change notification settings - Fork 200
fix(realtime): make Push associated to MainActor #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,13 +32,15 @@ | |||||||||
| var pushes: [String: PushV2] = [:] | ||||||||||
| } | ||||||||||
|
|
||||||||||
| private let mutableState = LockIsolated(MutableState()) | ||||||||||
| @MainActor | ||||||||||
| private var mutableState = MutableState() | ||||||||||
|
Check warning on line 36 in Sources/Realtime/RealtimeChannelV2.swift
|
||||||||||
|
|
||||||||||
| let topic: String | ||||||||||
| let config: RealtimeChannelConfig | ||||||||||
| let logger: (any SupabaseLogger)? | ||||||||||
| let socket: RealtimeClientV2 | ||||||||||
| var joinRef: String? { mutableState.joinRef } | ||||||||||
|
|
||||||||||
| @MainActor var joinRef: String? { mutableState.joinRef } | ||||||||||
|
|
||||||||||
| let callbackManager = CallbackManager() | ||||||||||
| private let statusSubject = AsyncValueSubject<RealtimeChannelStatus>(.unsubscribed) | ||||||||||
|
|
@@ -81,6 +83,7 @@ | |||||||||
| } | ||||||||||
|
|
||||||||||
| /// Subscribes to the channel | ||||||||||
| @MainActor | ||||||||||
| public func subscribe() async { | ||||||||||
| if socket.status != .connected { | ||||||||||
| if socket.options.connectOnSubscribe != true { | ||||||||||
|
|
@@ -109,7 +112,7 @@ | |||||||||
| ) | ||||||||||
|
|
||||||||||
| let joinRef = socket.makeRef() | ||||||||||
| mutableState.withValue { $0.joinRef = joinRef } | ||||||||||
| mutableState.joinRef = joinRef | ||||||||||
|
|
||||||||||
| logger?.debug("Subscribing to channel with body: \(joinConfig)") | ||||||||||
|
|
||||||||||
|
|
@@ -497,8 +500,8 @@ | |||||||||
| filter: filter | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| mutableState.withValue { | ||||||||||
| $0.clientChanges.append(config) | ||||||||||
| Task { @MainActor in | ||||||||||
| mutableState.clientChanges.append(config) | ||||||||||
| } | ||||||||||
|
Comment on lines
+503
to
505
|
||||||||||
| Task { @MainActor in | |
| mutableState.clientChanges.append(config) | |
| } | |
| mutableState.clientChanges.append(config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a breaking change since the method is
async, the call site already have to call this method with anawaitindependent of the running actor.