Skip to content

Commit

Permalink
Receiver map
Browse files Browse the repository at this point in the history
  • Loading branch information
psharanda committed Apr 21, 2017
1 parent c854aa3 commit 554a424
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Sources/Observable+Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ public extension Observable where ValueType: ResultConvertible {
}
}

public extension Observable where ValueType: Error {

public var localizedDescription: Observer<String> {
return map { $0.localizedDescription }
}
}




8 changes: 8 additions & 0 deletions Sources/Receiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ public struct Receiver<T>: Bindable {
}
}

extension Receiver {
public func map<U>(_ transform: @escaping (U) -> T) -> Receiver<U> {
return Receiver<U> {
self.update(transform($0))
}
}
}

extension Receiver where ValueType: Optionable {

/**
Expand Down

0 comments on commit 554a424

Please sign in to comment.