I have copied the code from the book in a Playground, exactly like so:
func story(id: Int) -> AnyPublisher<Story, Error> {
URLSession.shared.dataTaskPublisher(for: EndPoint.story(id).url)
.receive(on: apiQueue)
.map(\.data)
.decode(type: Story.self, decoder: decoder)
.catch { _ in Empty<Story, Error>() }
.eraseToAnyPublisher()
}
However, when I call the method, the debugger prints keyPath2()
for the completion rather than finished
. What am I doing wrong?
api.story(id: 1000)
.receive(on: DispatchQueue.main)
.sink(receiveCompletion: { print($0) }, receiveValue: { print($0) })
.store(in: &subscriptions)
Output:
How Important is the .com TLD?
by python_kiss
http://www.netbusinessblog.com/2007/02/19/how-important-is-the-dot-com/
-----
keyPath2()