> For the complete documentation index, see [llms.txt](https://cognitox.gitbook.io/cognito-kmm-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cognitox.gitbook.io/cognito-kmm-docs/handling-list-data.md).

# Handling list data

LazyColumnWithLoadingForList\<T>

### Example Usage of LazyColumnWithLoadingForList

**Scenario:**

Let's assume we're building a news app that fetches a list of articles from an API. We want to display the articles in a `LazyColumn` with appropriate loading, error, and empty state handling.

**Code Implementation:**

Kotlin

```kotlin
@Composable
fun NewsFeed() {
    val newsList = viewModel.newsList.collectAsState()

    LazyColumnWithLoadingForList(
        remoteData = newsList.value,
        emptyView = {
            Text(text = "No news found.")
        },
        itemView = { newsItem ->
            NewsItem(newsItem)
        }
    )
}
```

**Explanation:**

1. **Data Fetching:** The `newsList` state flow is used to collect the list of news articles from the view model.
2. **Component Usage:** The `LazyColumnWithLoadingForList` composable is used with the following parameters:
   * **`remoteData`:** The `newsList` state flow is passed to provide the data.
   * **`emptyView`:** A simple `Text` component is used to display a message when no news is found.
   * **`itemView`:** A custom `NewsItem` composable is used to render each news article.
3. **State Handling:** The component automatically handles the loading, error, and empty states based on the `remoteData` value.

**Additional Considerations:**

* **Error Handling:** You can customize the `errorView` parameter to provide more specific error messages or actions.
* **Pagination:** If your news API supports pagination, you can modify the `RemoteListData` type to include pagination information and update the `LazyColumnWithLoadingForList` component accordingly.
* **Loading Indicator:** The default loading view can be customized by providing a custom composable to the `loadingView` parameter.

**Benefits:**

* **Simplified Data Handling:** The component automatically handles loading, error, and empty states.
* **Efficient Rendering:** The `LazyColumn` ensures efficient rendering of the list items.
* **Customizability:** You can customize the appearance and behavior of the component to fit your specific needs.

By using `LazyColumnWithLoadingForList`, you can create a clean and efficient news feed component that provides a great user experience.
