From 9a47fff65484349bd10bc754fb22c9e9f82997d8 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Sun, 12 Nov 2017 22:07:46 +0300 Subject: [PATCH] fix total count cursor result sharing --- Sources/Classes/Cursors/TotalCountCursor.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/Classes/Cursors/TotalCountCursor.swift b/Sources/Classes/Cursors/TotalCountCursor.swift index b1acaf9b..c570331a 100644 --- a/Sources/Classes/Cursors/TotalCountCursor.swift +++ b/Sources/Classes/Cursors/TotalCountCursor.swift @@ -65,18 +65,19 @@ public final class TotalCountCursor: .map { [configuration] listing in configuration.getResult(from: listing) } + .asObservable() + .share() - let driverListing = sharedListing - .asDriver(onErrorJustReturn: CC.ResultTuple([], .max)) - - driverListing + sharedListing .map { $0.totalCount } + .asDriver(onErrorJustReturn: .max) .filter { $0 != .max } .drive(totalCountVariable) .disposed(by: disposeBag) - let newProductsDriver = driverListing + let newProductsDriver = sharedListing .map { $0.results } + .asDriver(onErrorJustReturn: []) .filterEmpty() Driver