I'm trying to compose AsyncSequence
of AsyncMessage
using functionality from the AsyncAlgorithms
package. However, this seems not supported because most of the algorithms in AsyncAlgorithms
require input sequences to be Sendable
(e.g. combineLatest
). NotificationCenter.default.messages
return some AsyncSequence<AsyncMessage, Never>
which does not conform to Sendable
.
Will this issue be addressed in AsyncAlgorithms 1.1, or have I overlooked something?
Here is some examples of code that illustrates the problem and does not compile:
import Foundation
import AsyncAlgorithms
struct MyMessage: NotificationCenter.AsyncMessage {
typealias Subject = AnyObject
}
@available(macOS 26.0, *)
func myFunc() async {
let trigger = AsyncStream(unfolding: { true })
let data = NotificationCenter.default.messages(
for: MyMessage.self
).compactMap { message -> Data? in
return Data()
}
let stream = combineLatest(
data,
trigger.removeDuplicates { _,_ in true }
)
for await (e, _) in stream {
}
}