Skip to content

Commit 4fcd651

Browse files
committed
Sendable
1 parent d84ef9b commit 4fcd651

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

Sources/LiveKit/Support/ObservableObject+.swift

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@
1818

1919
extension ObservableObject {
2020
/// An async sequence that emits the `objectWillChange` events.
21-
var changes: any AsyncSequence {
22-
if #available(macOS 12.0, iOS 15.0, tvOS 15.0, *) {
23-
// This is necessary due to ObservableObjectPublisher not respecting the demand.
24-
// See: https://forums.swift.org/t/asyncpublisher-causes-crash-in-rather-simple-situation
25-
objectWillChange.buffer(size: 1, prefetch: .byRequest, whenFull: .dropOldest).values
26-
} else {
27-
AsyncStream { continuation in
28-
let cancellable = objectWillChange.sink { _ in
29-
continuation.yield()
30-
}
31-
continuation.onTermination = { _ in
32-
cancellable.cancel()
33-
}
21+
var changes: AsyncStream<Void> {
22+
AsyncStream { continuation in
23+
let cancellable = objectWillChange.sink { _ in
24+
continuation.yield()
25+
}
26+
continuation.onTermination = { _ in
27+
cancellable.cancel()
3428
}
3529
}
3630
}

0 commit comments

Comments
 (0)