sergdort / CleanArchitectureRxSwift

Example of Clean Architecture of iOS app using RxSwift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash on asDriverOnErrorJustComplete function

ranhsd opened this issue · comments

Hi, I started to work on some side project which is based on this great project.

I facing some strange issue that when i execute a request from my view model to the server if the request failed the app crash. After debug it i found the crash is because the asserationFailure command check the error and because the error object is not nil the app crash.

This is the whole function:

func asDriverOnErrorJustComplete() -> Driver<E> { return asDriver { error in assertionFailure("Error \(error)") return Driver.empty() } }

My view model code is:

`
let login = input.loginTrigger.withLatestFrom(emailAndPassword)
.flatMapLatest({ [unowned self] (email, password) in

        return self.loginUseCase.login(username: email, password: password)
            .trackActivity(activityIndicator)
            .trackError(errorTracker)
            .asDriverOnErrorJustComplete()
    })

`

As you can see i use the same best practices like you use in your project.
I also tried to change your code so network requests will fail and the asDriverOnErrorJustComplete but from some reason on your project it ignore the asserationFailure line.
Can someone advice what should i do or what i am doing wrong?

thanks!

Hi, @ranhsd

You doing everything correctly, this is my mistake :) there should not be assertionFailure as it perfectly fine for execution to reach that point. It should be something like this

Hi @sergdort ,
Thanks, would you like me to do the fix and create a pull request ?

Sure, if you don’t mind :)

Hi @sergdort ,
i've created a pull request #25

Thanks,
Ran.

Cool! I guess we can close this one :)