Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RxSwift convert Observable<Bool> to Observable<Void>

I am not so convinced with RxSwift yet, and it's really hard to cleat understanding. After reviewing different materials, I cant' still work and manipulate sequences. On the whole I have problem with type converting:

Cannot convert return expression of type 'Observable<Bool>' to return type 'Observable<Void>' (aka 'Observable<()>')    

I have CocoaAction processing, and should return Observable<Void>

func stopProject() -> CocoaAction {
    return CocoaAction { _ in
        let stopProject = stop(project: self.projectId)
        return stopProject.asObservable() //wrong converting
    }
}

The stop function return Observable<Bool>

Finish view:

    return stop(project: self.projectId).flatMap { _ in
        Observable<Void>.empty()
    }
like image 919
biloshkurskyi.ss Avatar asked Aug 17 '17 13:08

biloshkurskyi.ss


1 Answers

let voidObservable = boolObservable.map { Void() }
like image 80
Maxim Volgin Avatar answered Sep 20 '22 07:09

Maxim Volgin