Develop record-breaking apps with MobilePro 📱, #1.2

0
58
5 min read

What’s happening in tech?

The week Android, Apple and Microsoft rolled out these announcements and updates:

Android

  • Wear Compose stable release – Wear Compose 1.01 stable version is now out! Write Jetpack Compose applications for Wearable devices by providing functionality to support wearable-specific devices, sizes, shapes, and navigation gestures.

Apple

  • WWDC22 video subtitles now in more languages – You can now watch the Keynote, Platforms State of the Union, and nearly 200 sessions from this year’s Apple Worldwide Developers Conference with Japanese, Korean, and Simplified Chinese subtitles. Available on the web or the Apple Developer app.
     
  • Xcode Cloud subscriptions now available – Xcode Cloud, the continuous integration and delivery service accelerates development and delivery. Configure a workflow in Xcode and receive 25 compute hours per month for free until the end of 2023. Subscribe for more compute hours in the Apple Developer app!
     
  • iOS 16 beta 8 – The iOS & iPadOS 16 SDK provides support to develop apps for iPhone, iPad, and iPod touch devices running iOS & iPadOS 16 beta 7. The SDK comes bundled with Xcode 14 beta 6, available from Beta Software Downloads.
     

Microsoft 


  • Python in Visual Studio Code – September 2022 Release – The company announced the September 2022 release of the Visual Studio Code Python and Jupyter extensions. This release includes the following announcements Improved IntelliSense support for Jupyter Notebooks, A new Flake8 extension, and Internship highlight: improved unit test support and notebook image pasting
  • .NET MAUI Cloud Skills Challenge – Learn .NET MAUI, Get Stickers! – The .NET MAUI Cloud Skills Challenge is a fun and exciting way to learn .NET MAUI and grab the latest .NET MAUI sticker swag! Sign up and finish all the .NET MAUI training modules for a chance to win. The challenge is now extended from August 31 to September 30 so more people can join in!
     
  • Dual-screen example adds Jetpack Compose to the experience – This week, two big updates to the dual-screen experience example: a Compose refactor of the catalog page and a brand new order history page were announced. The dual-screen experience example provides an end-to-end experience centered around a traveling guitar salesperson, with options to find fake guitar stores, read a catalog, browse products, place fake guitar orders, and now, view order history.

 

Weekly Picks

We’ve picked out some interesting articles from the tech world for you:

 

Tutorial of the Week

Kotlin Flows

Flow is a new Kotlin asynchronous stream library that is built on top of Kotlin coroutines. A flow can emit multiple values instead of a single value and over a period of time. Kotlin Flow is ideal to use when you need to return multiple values asynchronously, such as automatic updates from your data source.

Flow is now used in Jetpack libraries such as Room-KTX and Android developers are already using Flow in their applications.

To use Kotlin Flows in your Android project, you have to add coroutines. An easy way to create a flow of objects is to use the flow{} builder. With the flow{} builder function, you can add values to the stream by calling emit.

Let’s say in your Android app you have a getTextFromNetwork function that fetches text from a network endpoint and returns it as a String object:

fun getTextFromNetwork(): String { ... }

If we want to create a flow of each word of the text, we can do it with the following code:

private fun getWords(): Flow<String> = flow {
  getTextFromNetwork().split(" ").forEach {
    delay(1_000)
    emit(it)
  }
}

Flow does not run or emit values until the flow is collected with any terminal operators, such as collectlaunchIn, or single. You can use the collect() function to start the flow and process each value, as follows:

private suspend fun displayWords() {
          getWords().collect {
          Log.d("flow", it)
           }
}

A visual representation of this flow is shown in the following figure:

Figure 1.7 – Kotlin Flow visual representation

Figure 1.7 – Kotlin Flow visual representation

As you can see in Figure 1.7, as soon as the getWords() flow emits a string, the displayWords function collects the string and displays it immediately on the logs.

In this section, you learned about Kotlin coroutines and flows, the recommended way to carry out asynchronous programming in Android. Coroutines is a Kotlin library for managing long-running tasks in the background. Flow is a new Kotlin asynchronous stream library, built on top of coroutines, that can emit multiple values over a period of time.
 

This how-to was curated from the book  
Simplifying Android Development with Coroutines and Flows

👇 Hit the button to take a deeper dive into the world of Android! 👇

Read the Book