-
Notifications
You must be signed in to change notification settings - Fork 433
Open
Labels
Description
I haven’t tried the new betas yet, but I imagine the prevalence of @MainActor in iOS 15 will bring issues to current uses of ReactiveSwift.
Specifically, I imagine you won’t be able to just do this:
producer
.observe(on: UIScheduler())
.start { [label] in label.text = $0 }Feature request:
for await value in producer.start() {
self.label.text = value
}Unfortunately for try await would mean we lose error type information, so I would propose this API produces Result<Value, Error>, or a sequence of Value if Error is Never.
I’ll probably work on this throughout the week, but other thoughts are appreciated!
References:
- https://github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md
- https://github.com/apple/swift-evolution/blob/main/proposals/0314-async-stream.md
Other ideas:
- Being able to create
SignalProducers usingasync:
SignalProducer<Int, MyError> { observer, disposable in
observer.send(value: await f1())
guard !disposable.isDisposed else { return }
do {
observer.send(value: try await f2())
} catch {
observer.send(error: error)
}
}- Or simply just one
asyncfunction:
let producer = SignalProducer<Int, Error>(asyncFunction: f)- New
collectoverloads:
let values: [Int] = await producer.collect()
let result: Result<[Int], MyError> = try await producer.collect()mluisbrown and kumabook