Skip to content

Commit 9afc78e

Browse files
committed
fix(ios): make awaitViewReady reentrant, support multiple callers
1 parent e2bb152 commit 9afc78e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

ios/new/RiveReactNativeView.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class RiveReactNativeView: UIView {
2323
private var riveUIView: RiveUIView?
2424
private var riveInstance: RiveRuntime.Rive?
2525
private var eventListeners: [(UnifiedRiveEvent) -> Void] = []
26-
private var viewReadyContinuation: CheckedContinuation<Void, Never>?
26+
private var viewReadyContinuations: [CheckedContinuation<Void, Never>] = []
2727
private var isViewReady = false
2828
private var configTask: Task<Void, Never>?
2929
private var isPaused = false
@@ -33,7 +33,7 @@ class RiveReactNativeView: UIView {
3333
func awaitViewReady() async -> Bool {
3434
if !isViewReady {
3535
await withCheckedContinuation { continuation in
36-
viewReadyContinuation = continuation
36+
viewReadyContinuations.append(continuation)
3737
}
3838
}
3939
return true
@@ -108,8 +108,10 @@ class RiveReactNativeView: UIView {
108108

109109
if !self.isViewReady {
110110
self.isViewReady = true
111-
self.viewReadyContinuation?.resume()
112-
self.viewReadyContinuation = nil
111+
for continuation in self.viewReadyContinuations {
112+
continuation.resume()
113+
}
114+
self.viewReadyContinuations.removeAll()
113115
}
114116
RCTLog("[RiveReactNativeView] Configuration complete!")
115117
} catch {

0 commit comments

Comments
 (0)