Skip to content

Consuming the flows safely in Compose

Devrath edited this page May 4, 2024 · 3 revisions

Introduction

  • Collecting the flows in a lifecycle-aware manner is the recommended way to consume the flows if you are using the jetpack compose.
  • We can use the collectAsStateWithLifecycle API to achieve this.

Background

  • The collectAsStateWithLifecycle API can help conserve the app resources
  • Say your application is in the background, Here the flow does not need to be active. If it is active it may impact the device's health.
  • The queries include data-base connections, firebase queries, network-connections etc.

Visulization

1 drawio

Clone this wiki locally