July 2018
Intermediate to advanced
266 pages
7h 11m
English
Now we can do the actual implementation for the search. First we want to add a list of feeds to the Searcher class, and also a dispatcher and a document factory to retrieve the articles:
class Searcher() { val dispatcher = newFixedThreadPoolContext(3, "IO-Search") val factory = DocumentBuilderFactory.newInstance() val feeds = listOf( Feed("npr", "https://www.npr.org/rss/rss.php?id=1001"), Feed("cnn", "http://rss.cnn.com/rss/cnn_topstories.rss"), Feed("fox", "http://feeds.foxnews.com/foxnews/latest?format=xml") ) ...}
Now we can add a search() function that will retrieve a feed, filter the articles containing the given query on the title or the description, and send them through a SendChannel received ...
Read now
Unlock full access