Wujo
Wujo

Reputation: 1867

RxAlamofire - event on download completed missing

I'm using RxAlamofire for downloading file. I have something like this:

let downloadResult = download(request, to: destination)

Unfortunately downloadResult observable doesn't emit next event on download completed, it only emits onCompleted.

I need next event when download is finished to flatMap to next request. At the moment I'm basing on progress (download progress >= 1) to emit the event I'm interested in.

But I feel that it's not the best solution, for now it works, however I'm afraid this aproach may fail in some situation.

Can you suggest something? Do I miss something in RxAlamofire download api?

Upvotes: 1

Views: 665

Answers (1)

Valérian
Valérian

Reputation: 1118

Maybe something like this ?

Single<Void>.create { observer in
    return download(request, to: destination)
        .subscribe(onCompleted: {
            observer(.success(()))
        }, onError: {
            observer(.error($0))
        })

Upvotes: 0

Related Questions