RxSwift conver Observable<Bool> to Observable<Void>

Question

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()
    }

Show source
| generics   | swift   | ios   | sequence   | rx-swift   2017-08-17 15:08 1 Answers

Answers to RxSwift conver Observable&lt;Bool&gt; to Observable&lt;Void&gt; ( 1 )

  1. 2017-08-17 16:08
    let voidObservable = boolObservable.map { Void() }
    

Leave a reply to - RxSwift conver Observable<Bool> to Observable<Void>

◀ Go back