Refactor PollHistoryService

This commit is contained in:
Alfonso Grillo
2023-01-23 12:04:24 +01:00
parent 9cc9a046fe
commit 9b16774d6a
5 changed files with 130 additions and 137 deletions
@@ -17,22 +17,8 @@
import Combine
protocol PollHistoryServiceProtocol {
/// Publishes poll data as soon they are found in the timeline.
/// Updates are also published here, so clients needs to address duplicates.
var pollHistory: AnyPublisher<TimelinePollDetails, Never> { get }
var updates: AnyPublisher<TimelinePollDetails, Never> { get }
var updatesErrors: AnyPublisher<Error, Never> { get }
/// Publishes whatever errors produced during the sync.
var error: AnyPublisher<PollHistoryError, Never> { get }
/// Ask to fetch the next batch of polls.
/// Concrete implementations can decide what a batch is.
func next()
/// Inform whenever the fetch of a new batch of polls starts or ends.
var isFetching: AnyPublisher<Bool, Never> { get }
}
enum PollHistoryError: Error {
case paginationFailed(Error)
case pollAggregationFailed(Error)
func next() -> AnyPublisher<TimelinePollDetails, Error>
}