Skip to content

Commit

Permalink
ci: work around type ambiguity in macOS 13 swift build (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcprux authored Nov 22, 2024
1 parent d81fc86 commit d0655a8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Sources/Realtime/RealtimeChannel+AsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ extension RealtimeChannelV2 {
filter: String? = nil
) -> AsyncStream<InsertAction> {
postgresChange(event: .insert, schema: schema, table: table, filter: filter)
.compactMap { $0.wrappedAction as? InsertAction }
.eraseToStream()
.compactErase()
}

/// Listen for postgres changes in a channel.
Expand All @@ -43,8 +42,7 @@ extension RealtimeChannelV2 {
filter: String? = nil
) -> AsyncStream<UpdateAction> {
postgresChange(event: .update, schema: schema, table: table, filter: filter)
.compactMap { $0.wrappedAction as? UpdateAction }
.eraseToStream()
.compactErase()
}

/// Listen for postgres changes in a channel.
Expand All @@ -55,8 +53,7 @@ extension RealtimeChannelV2 {
filter: String? = nil
) -> AsyncStream<DeleteAction> {
postgresChange(event: .delete, schema: schema, table: table, filter: filter)
.compactMap { $0.wrappedAction as? DeleteAction }
.eraseToStream()
.compactErase()
}

/// Listen for postgres changes in a channel.
Expand Down Expand Up @@ -126,3 +123,10 @@ extension RealtimeChannelV2 {
broadcastStream(event: event)
}
}

// Helper to work around type ambiguity in macOS 13
fileprivate extension AsyncStream<AnyAction> {
func compactErase<T: Sendable>() -> AsyncStream<T> {
AsyncStream<T>(compactMap { $0.wrappedAction as? T } as AsyncCompactMapSequence<Self, T>)
}
}

0 comments on commit d0655a8

Please sign in to comment.