From 84f3926fe0c96d5dbf1002f4261a76deef17e9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mate=CC=8Cj=20Kas=CC=8Cpar=20Jira=CC=81sek?= Date: Tue, 26 Jan 2021 11:53:34 +0100 Subject: [PATCH] Make endpoint publisher internal --- Sources/FTAPIKit/Combine/EndpointPublisher.swift | 8 ++++---- Sources/FTAPIKit/Combine/URLServer+Combine.swift | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Sources/FTAPIKit/Combine/EndpointPublisher.swift b/Sources/FTAPIKit/Combine/EndpointPublisher.swift index cd330d0..02af89e 100644 --- a/Sources/FTAPIKit/Combine/EndpointPublisher.swift +++ b/Sources/FTAPIKit/Combine/EndpointPublisher.swift @@ -5,15 +5,15 @@ import Combine @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) extension Publishers { - public struct Endpoint: Publisher { - public typealias Output = R - public typealias Failure = E + struct Endpoint: Publisher { + typealias Output = R + typealias Failure = E typealias Builder = (@escaping (Result) -> Void) -> URLSessionTask? let builder: Builder - public func receive(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input { + func receive(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input { let subscription = EndpointSubscription(subscriber: subscriber, builder: builder) subscriber.receive(subscription: subscription) } diff --git a/Sources/FTAPIKit/Combine/URLServer+Combine.swift b/Sources/FTAPIKit/Combine/URLServer+Combine.swift index 24a48e1..a791300 100644 --- a/Sources/FTAPIKit/Combine/URLServer+Combine.swift +++ b/Sources/FTAPIKit/Combine/URLServer+Combine.swift @@ -4,28 +4,32 @@ import Combine @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) public extension URLServer { - func publisher(endpoint: Endpoint) -> Publishers.Endpoint { + func publisher(endpoint: Endpoint) -> AnyPublisher { Publishers.Endpoint { completion in self.call(endpoint: endpoint, completion: completion) } + .eraseToAnyPublisher() } - func publisher(data endpoint: Endpoint) -> Publishers.Endpoint { + func publisher(data endpoint: Endpoint) -> AnyPublisher { Publishers.Endpoint { completion in self.call(data: endpoint, completion: completion) } + .eraseToAnyPublisher() } - func publisher(response endpoint: EP) -> Publishers.Endpoint { + func publisher(response endpoint: EP) -> AnyPublisher { Publishers.Endpoint { completion in self.call(response: endpoint, completion: completion) } + .eraseToAnyPublisher() } - func publisher(download endpoint: Endpoint) -> Publishers.Endpoint { + func publisher(download endpoint: Endpoint) -> AnyPublisher { Publishers.Endpoint { completion in self.download(endpoint: endpoint, completion: completion) } + .eraseToAnyPublisher() } }