Search code examples
swiftrx-swiftthrows

Cannot convert value of type '(() throws -> Void?) -> ()' to expected argument type '((Void) throws -> Void)?'


I have a reactive method who should return ((Void) throws -> Void)? to be used into .on(onNext: myUIComponent.rx.function) but no matters what I do I never get what is expected.

I was tries

func name() throws -> Void?

func name(xpto: ((Void) throws -> Void?) = nil)

Someone have some idea?


Solution

  • D'oh, nothing is necessary, just create a func name() without return like

    extension Reactive where Base: ReactiveUIComponent {
        func name() {
            ...
        }
    }
    
    button.rx.tap
        .do(onNext: reactiveUIComponent.rx.name)
        ...