Skip to content

Instantly share code, notes, and snippets.

@devxoul
Created May 28, 2017 20:04
Show Gist options
  • Select an option

  • Save devxoul/ca0f1ecb78c2ef51fdb0045a6c77086f to your computer and use it in GitHub Desktop.

Select an option

Save devxoul/ca0f1ecb78c2ef51fdb0045a6c77086f to your computer and use it in GitHub Desktop.
extension ObservableType where E: Any {
func map<T: ImmutableMappable>(_ mappableType: T.Type) -> Observable<T> {
return self
.map { try Mapper<T>().map(JSONObject: $0) }
.do(onError: { error in
if error is MapError {
log.error(error)
}
})
}
func map<T: ImmutableMappable>(_ mappableType: [T].Type) -> Observable<[T]> {
return self
.map { try Mapper<T>().mapArray(JSONObject: $0) }
.do(onError: { error in
if error is MapError {
log.error(error)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment