I’ll write more about this shortly, but yesterday I created a little video of a demo application I call Futureboard. It’s a Scala/Swing application, but it works like Flipboard in that it updates a number of panels — in this case Java JInternalFrames — simultaneously every time you ask it to update.
The “update” process works by creating Scala futures, one for each internal frame. When you select File > Update, a Future is created for each news source, and then simultaneous calls are made to each news source, and their frames are updated when the data returns. (Remember that Futures are good for one-shot, “handle this relatively slow and potentially long-running computation, and call me back with a result when you’re done” uses.)
Here’s the two-minute demo video:
If that video isn’t showing up, you can view it on YouTube at this link.
I wrote about this app in the “Scala Futures” section of my book, Functional Programming, Simplified, and I just spent a little time this past week improving the code a little bit so you can focus on the Futures and see less of the rest of the code.
You can see the relevant source code in the video — select high-quality mode in YouTube, if necessary — so I’m not taking the time to share it here today. (Too many things to do atm.) As one code-related note, you can see in the video that a new Future is created for each data source (news source). As a second note, you can also see that I added a random delay to each call to make the parallel nature of the code more obvious. I also slowed down the video a little bit in the areas where the frames are updated so you can see that they are random. The actual code runs much faster than what’s shown in the video.
When I get a few more free moments I’ll write about the application and share the source code, but that’s what I have for today.
this post is sponsored by my books: | |||
#1 New Release |
FP Best Seller |
Learn Scala 3 |
Learn FP Fast |