-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support await / AsyncSequence #830
Comments
It should be modelled as a conversion to It could also be The nuance is likely around dealing with the scenario of a fast producer against a slow consumer. To achieve the deliver exactly once default of today’s RAS, we probably need to use unlimited buffering with the (supposedly available) (That is assuming we throw away all the blocking options) |
Another thing worth watching is whether Swift Concurrency will end up backward deployed. Async-await is really a natural way to express backpressure (callee can defer return of control flow by holding onto the continuation), especially personally having had a hands-on experience of it in Kotlin Coroutines. So that’s honestly how I would see proper backpressure being introduced into RAS, versus the Combine/Reactive Streams model (works but sometimes brittle). (especially relevant since the proposed AsyncSequence stuff did not grow into a full fledged FRP toolbox, which means there are still values in using community libraries like RAS). Either way, for now, we should bet on basically simple interops. |
It became known that async / await mechanism is not backward deployed :( It's require new runtime. It's a pity |
Edit: fixed implementation for RC: I quickly prototyped this on Beta 3 and it works: @available(iOS 15.0, *)
@available(tvOS 15.0, *)
@available(watchOS 8.0, *)
@available(macCatalystApplicationExtension 15.0, *)
extension SignalProducer {
public func start() -> AsyncStream<Result<Value, Error>> {
return AsyncStream(Result<Value, Error>.self) { continuation in
let disposable = self.start { event in
switch event {
case let .value(value): continuation.yield(.success(value))
case let .failed(error): continuation.yield(.failure(error))
case .completed, .interrupted: continuation.finish()
}
}
continuation.onTermination = { @Sendable _ in disposable.dispose() }
}
}
}
@available(iOS 15.0, *)
@available(tvOS 15.0, *)
@available(watchOS 6.0, *)
@available(macCatalystApplicationExtension 15.0, *)
func f() async {
let p = SignalProducer<Int, Never>([1, 2, 3])
for try await x in p.start() {
print(x)
}
} Unfortunately we don't have a way to test these things right now until Quick/Quick#1084. |
Luckily that's no longer true! :) |
@NachoSoto who knows how long this process will take... |
What process? |
@NachoSoto I guess @danya61 is referring to this PR which I think is the last piece in back porting concurrency to older OSes. (looks like it will be iOS 13, macOS 10.15). |
Back-deploy concurrency |
maybe https://github.com/ReactiveX/RxSwift/releases/tag/6.5.0 can serve as an example / template ? |
What about using AsyncThrowingStream to handle the errors without using Result? |
We would use the Error type information. |
Hi! @andersio But in our team we have concerns mixing Thanks in advance. Br, Darko |
I haven’t tried the new betas yet, but I imagine the prevalence of
@MainActor
iniOS 15
will bring issues to current uses ofReactiveSwift
.Specifically, I imagine you won’t be able to just do this:
Feature request:
Unfortunately
for try await
would mean we lose error type information, so I would propose this API producesResult<Value, Error>
, or a sequence ofValue
ifError
isNever
.I’ll probably work on this throughout the week, but other thoughts are appreciated!
References:
Other ideas:
SignalProducer
s usingasync
:async
function:collect
overloads:The text was updated successfully, but these errors were encountered: