Skip to content
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

AsyncSequence.asObservable() effect is not as expected #2553

Open
5 of 18 tasks
Mx-Iris opened this issue Nov 1, 2023 · 0 comments
Open
5 of 18 tasks

AsyncSequence.asObservable() effect is not as expected #2553

Mx-Iris opened this issue Nov 1, 2023 · 0 comments

Comments

@Mx-Iris
Copy link
Contributor

Mx-Iris commented Nov 1, 2023

The following code looks the same. cloneProgress returns an AsyncThrowStream, but using asObservable causes it to work on the main thread (the thread from which this code is executed).

// This will cause the code in the Task to run in the current thread (in my case, the main thread).
return AsyncSwiftGit.Repository.cloneProgress(from: remoteURL, to: localURL, credentials: credentials).asObservable()

// This works as expected, but it just pulls the asObservable code out
return .create { observer in
    let task = Task {
        do {
            for try await value in AsyncSwiftGit.Repository.cloneProgress(from: remoteURL, to: localURL, credentials: credentials) {
                observer.onNext(value)
            }
            observer.onCompleted()
        } catch {
            observer.onError(error)
        }
    }
    return Disposables.create {
        task.cancel()
    }
}

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

6.6.0

Platform/Environment

  • iOS
  • macOS
  • tvOS
  • watchOS
  • playgrounds

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

  • easy, 100% repro
  • sometimes, 10%-100%
  • hard, 2% - 10%
  • extremely hard, %0 - 2%

Xcode version:

  15.0.0

⚠️ Fields below are optional for general issues or in case those questions aren't related to your issue, but filling them out will increase the chances of getting your issue resolved. ⚠️

Installation method:

  • CocoaPods
  • Carthage
  • SwiftPM
  • Git submodules

I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)

  • yes (which ones)
  • no

Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)

  • just starting
  • I have a small code base
  • I have a significant code base
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant