Skip to content

RxSwift SwiftConcurrecy StrongSelf ISSUE #2658

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

Open
Little-tale opened this issue Mar 19, 2025 · 1 comment
Open

RxSwift SwiftConcurrecy StrongSelf ISSUE #2658

Little-tale opened this issue Mar 19, 2025 · 1 comment

Comments

@Little-tale
Copy link

Little-tale commented Mar 19, 2025

This is a problem I found while using RxSwift. Version 6.8.0

     Task {
            for try await payload in daView.buildingWebViewAction.values {
                switch payload.type {
                case .disableScroll:
                    guard let bool = payload.data as? Bool else { return }
                   scrollView.isScrollEnabled = !bool
                default:
                    break
                }
            }
        }

       OR 

        Task { [weak self] in
            guard let weakSelf = self else { return }
            
            for try await payload in daView.buildingWebViewAction.values {
                switch payload.type {
                case .disableScroll:
                    guard let bool = payload.data as? Bool else { return }
                    weakSelf.scrollView.isScrollEnabled = !bool
                default:
                    break
                }
            }
        }

When I wrote the code as above
View Controller Deinit is not invoked
It's happening.

        daView.buildingWebViewAction
            .bind(with: self) { owner, payload in
                switch payload.type {
                case .disableScroll:
                    guard let bool = payload.data as? Bool else { return }
                    owner.scrollView.isScrollEnabled = !bool
                default:
                    break
                }
            }
            .disposed(by: rx.disposeBag)

However, if I modify the code as applicable
Deinit is being called normally.

Is there anything I missed?
I would appreciate it if you could tell me how to solve it

@Little-tale Little-tale changed the title RxSwift SwiftConcurrecy StronSelf ISSUE RxSwift SwiftConcurrecy StrongSelf ISSUE Mar 19, 2025
@danielt1263
Copy link
Collaborator

danielt1263 commented Mar 19, 2025

If you put a .debug() on your stream. What is the output? Does it ever complete?

This would be a better question to ask on the RxSwift slack channel...

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

2 participants