-
Should be
map
for the second one, and no need to specify return types for one-liners:firstly { session.dataTask(.promise, with: url) }.map(on: queue) { data, response in try JSONSerialization.jsonObject(with: data, options: []) as? [String : Any] }.compactMap(on: queue) { imageDict in self.factory.getImage(fromDict: imageDict) }
Edited by Max Howell -
You're right about the return types, but I wanted to point out in the examples that the data is being pushed down the chain.
I suppose since we're using the 'try' it will either throw or create the dict, so it can be a .map. I just followed the original example set by: https://github.com/mxcl/PromiseKit/blob/master/Documentation/CommonPatterns.md
Please register or sign in to comment