1
votes

For each, Event, I want need to send it and validate it. I have this code:

fun process(): Completable = 
    eventsDao.findAll()
        .flatMapCompletable(this::sendEventToServer)
        .andThen(this::validate) //Error here

fun send(event: Event): Completable = 
    //code 

fun validate(event: Event): Completable =
    //code

Error:(14, 18) None of the following functions can be called with the arguments supplied: @CheckReturnValue @SchedulerSupport public final fun andThen(p0: ((CompletableObserver) -> Unit)!): Completable! defined in io.reactivex.Completable

@CheckReturnValue @SchedulerSupport public final fun andThen(p0: ((MaybeObserver) -> Unit)!): Maybe<(???..???)>! defined in io.reactivex.Completable

@CheckReturnValue @SchedulerSupport public final fun andThen(p0: ((Observer) -> Unit)!): Observable<(???..???)>! defined in io.reactivex.Completable

and so on

Problem is that here:

.andThen(this::validate)

I don't have the event itself. How can I chain these Completables?

1

1 Answers

1
votes

I found an answer:

fun process(): Completable = 
    eventsDao.findAll()
        .flatMapCompletable(this::processEvent)

fun processEvent(event: Event) =
    send(event).concatWith(validate(event))

I will really appreciate any advice or a better manner to do it