RxSwift icon indicating copy to clipboard operation
RxSwift copied to clipboard

fix(#2553) : AsyncSequence.asObservable() runs on background thread

Open suojae opened this issue 9 months ago • 0 comments

Fixes #2553

Problem Description

The current implementation of AsyncSequence.asObservable() can potentially execute on the main thread, which may cause UI blocking issues. This becomes especially problematic when the AsyncSequence performs time-consuming operations.

Changes

Modified AsyncSequence.asObservable() to use Task.detached, ensuring the sequence always runs on a background thread. This change guarantees that AsyncSequence operations won't block the main thread.

Testing

  • Successfully passed all existing tests
  • Added and passed test cases that verify execution on background threads
  • Included additional test cases covering edge scenarios (with sleep operations, error handling)

suojae avatar Apr 16 '25 02:04 suojae