.flatMap() parts of the flow can become really complicated. Often, they contain nested calls to multiple .map(), Observable.just(), and other functions.
This makes the .flatMap() Function interfaces a prime candidate for simplification by method extraction. At the moment, consider the tweet retrieval part (the version that doesn't use for loop to filter tweets):
observeTwitterStream(configuration, filterQuery) .sample(2700, TimeUnit.MILLISECONDS) .map(StockUpdate::create) .flatMapMaybe(update -> Observable.fromArray(trackingKeywords) .filter(keyword -> update.getTwitterStatus().toLowerCase() .contains(keyword.toLowerCase())) .map(keyword -> update) .firstElement() )
It has such a flow where the following bit can be extracted ...