RxSwiftCommunity / Action

Abstracts actions to be performed in RxSwift.
MIT License
875 stars 150 forks source link

auto-release Action in function scope #241

Open Osama-Fawzi opened 2 years ago

Osama-Fawzi commented 2 years ago

HI Guys, I think I need just an enlighten or clarification, what is the reason that makes action2 deallocate and never receive any events from button 2, while action 3 is working fine...

I have double checked the memory and it's confirming the observation.

Screen Shot 2022-10-02 at 03 56 17
let action1 = Action<String, String> { input in
        print(input)
        return .just(input)
    }

    func textActions() {
        let action2 = Action<String, String> { input in
            print(input)
            return .just(input)
        }

        let action3 = CocoaAction { _ in
            print("Test")
            return .empty()
        }

        button1
            .map { _ in "Test 1" }
            .bind(to: action1.inputs)
            .disposed(by: disposableBag)

        button2
            .map { _ in "Test 2" }
            .bind(to: action2.inputs)
            .disposed(by: disposableBag)

        button3.rx.action = action3
    }