MutableStateFlow

Depending on the state your application needs to manage, you may find that the flow builder you have been using is fairly restrictive. Only the lambda expression you provide can emit items into the flow. This worked well to update the departure time of a flight, since the departure time can be updated automatically as time progresses. But other parts of your application will need to allow multiple components to influence their state.

To help users tracking multiple flights, TaernylAir should tell users how many flights are queued to be tracked. The state you need to track for this is the number of flights that are at the gate, waiting for passengers to board. But the flow builder is not a good tool for this task, ...

Get Kotlin Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.