Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions ios/RowndPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ class RowndPlugin: NSObject {
// Note: Subsequent calls to configure() will not reinitialize the state subscription
// if it has already been initialized. This is intentional to prevent duplicate subscriptions.
if self.state == nil {
let initializedState = Rownd.getInstance().state().subscribe { $0 }
self.state = initializedState
self.stateCancellable = initializedState.$current.sink { newState in
do {
RowndPluginEventEmitter.emitter.sendEvent(
withName: "update_state", body: try newState.toDictionary())
} catch {
print("Failed to encode Rownd state: \(String(describing: error))")
Task { @MainActor [weak self] in
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): The placement of @MainActor relative to the capture list is likely invalid Swift syntax.

In closure syntax, attributes must come before the capture list: { @MainActor [weak self] in ... } is invalid. This will not compile as written. Consider either Task { @MainActor in ... } (no capture list) or Task { [weak self] @MainActor in ... }, which preserves both main-actor isolation and the weak capture.

guard let self = self, self.state == nil else { return }
let initializedState = Rownd.getInstance().state().subscribe { $0 }
self.state = initializedState
self.stateCancellable = initializedState.$current.sink { newState in
do {
RowndPluginEventEmitter.emitter.sendEvent(
withName: "update_state", body: try newState.toDictionary())
} catch {
print("Failed to encode Rownd state: \(String(describing: error))")
}
}
}
}
Expand Down