Skip to content

RxSwift SwiftConcurrecy StrongSelf ISSUE #2658

Open
@Little-tale

Description

@Little-tale

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions