Skip to content

Instantly share code, notes, and snippets.

@masliukivskyi
Created May 3, 2020 20:24
Show Gist options
  • Save masliukivskyi/9dd513d4ab45c0a1ef979eefa2ce8aa4 to your computer and use it in GitHub Desktop.
Save masliukivskyi/9dd513d4ab45c0a1ef979eefa2ce8aa4 to your computer and use it in GitHub Desktop.
Combining
_ = dataProvider
.decode(type: DummyDecodable.self, decoder: JSONDecoder())
.map({ (decodable) -> String in
return "The user is \(decodable.userName) and his id is \(decodable.userId)"
})
.sink(receiveCompletion: { completion in
print(completion)
}, receiveValue: { response in
print(response)
})
dataProvider.send(Data("{\"userName\":\"Alex\",\"userId\":1}".utf8))
Output: The user is Alex and his id is 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment