i am using twitter4s https://github.com/DanielaSfregola/twitter4s here it shows how to we get the twitter stream and stops it
def simulateNextActionAfterMillis(millis: Long): Future[Unit] = Future {
Thread.sleep(millis); println()
}
for {
streamA <- streamingClient.sampleStatuses(stall_warnings = true)(printTweetText)
_ <- simulateNextActionAfterMillis(10000)
} yield streamA.close()
def printTweetText: PartialFunction[StreamingMessage, Unit] = {
case tweet: Tweet =>
println(tweet.text)
}
all i want is the total tweets object after the stream closes how can i get that ?
I could not really understand your issue by looking at the code, so can not answer the real question.
But I thought to point out that you should never simulate a future by "sleeping" on a thread.
You can create a non-blocking future using following,