From f58075d6bbd50dea1faf77acd049830ad242f99f Mon Sep 17 00:00:00 2001 From: KristofZelei Date: Tue, 20 Jun 2023 11:33:35 +0200 Subject: [PATCH] feat: add skipErrors operator --- Sources/Operators/SkipErrors.swift | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Sources/Operators/SkipErrors.swift diff --git a/Sources/Operators/SkipErrors.swift b/Sources/Operators/SkipErrors.swift new file mode 100644 index 0000000..41aadbe --- /dev/null +++ b/Sources/Operators/SkipErrors.swift @@ -0,0 +1,20 @@ +// +// SkipErrors.swift +// +// +// Created by Kristof Zelei on 2023. 06. 20.. +// Copyright © 2023. Supercharge Ltd. All rights reserved. +// + +#if canImport(Combine) +import Combine + +extension Publisher where Failure == Error { + public func skipErrors() -> AnyPublisher { + map { Optional($0) } + .replaceError(with: nil) + .compactMap { $0 } + .eraseToAnyPublisher() + } +} +#endif