From 554a42488ea0d0d984bbeae253f4bb6a64496967 Mon Sep 17 00:00:00 2001 From: Pavel Sharanda Date: Fri, 21 Apr 2017 15:52:56 +0300 Subject: [PATCH] Receiver map --- Sources/Observable+Result.swift | 10 ++++++++++ Sources/Receiver.swift | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/Sources/Observable+Result.swift b/Sources/Observable+Result.swift index 5a7d637..cfd723e 100644 --- a/Sources/Observable+Result.swift +++ b/Sources/Observable+Result.swift @@ -20,3 +20,13 @@ public extension Observable where ValueType: ResultConvertible { } } +public extension Observable where ValueType: Error { + + public var localizedDescription: Observer { + return map { $0.localizedDescription } + } +} + + + + diff --git a/Sources/Receiver.swift b/Sources/Receiver.swift index 14e6ac9..ace5520 100644 --- a/Sources/Receiver.swift +++ b/Sources/Receiver.swift @@ -21,6 +21,14 @@ public struct Receiver: Bindable { } } +extension Receiver { + public func map(_ transform: @escaping (U) -> T) -> Receiver { + return Receiver { + self.update(transform($0)) + } + } +} + extension Receiver where ValueType: Optionable { /**