CombineCommunity / CombineCocoa

Combine publisher bridges for UIKit
MIT License
1.67k stars 133 forks source link

can't assign Publisher to Button Tapped Publisher #72

Closed knight6700 closed 2 years ago

knight6700 commented 2 years ago

Describe the bug Key path value type 'ReferenceWritableKeyPath<UIButton, Void>' cannot be converted to contextual type 'KeyPath< UIButton, Void>'To Reproduce var tappedSubject = CurrentValueSubject<Void,Never>({}()) var signUPTapped: AnyPublisher<Void, Never> { tappedSubject.map {_ in self.showAlert() } .eraseToAnyPublisher() }

    viewModel.tappedSubject
        .assign(to: \.tapPublisher, on: signUpButton)

i get error when do this

freak4pc commented 2 years ago

I'm not entirely sure what you're trying to do here. signUpButton.tapPublisher is a Publisher. You can't assign anything to it.

knight6700 commented 2 years ago

I'm not entirely sure what you're trying to do here.

signUpButton.tapPublisher is a Publisher. You can't assign anything to it.

I'm trying to assign it to another publisher in viewModel to make navigation i don't want to use @IBAction

freak4pc commented 2 years ago

@knight6700 You can't assign anything to a publisher :) Publishers are read-only entities you can sink on to wait for their values.

Your question isn't related to CombineCocoa directly, so I suggest either trying StackOverflow or one of the available iOS Slack channels.

Thanks!