Skip to content

Conversation

@thedmail
Copy link
Contributor

No description provided.

@snippet-bot
Copy link

snippet-bot bot commented Sep 17, 2024

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Comment on lines 796 to 797
// Text(message.sender), where "message" is an object with a sender property
// Text(message.text), where "text" is an object with a text property
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be uncommented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Because there's no actual message class anywhere that has a sender or text property, and this example was too complex for me to set something up idiomatically (at least in a time-efficient way).

If you feel it's necessary to have this in code, could I ask you to implement it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a simple class to represent the message structure is a common practice in DAC snippets. It helps make the code compile and snippets readable instead of the code being commented out.

While it's not strictly necessary for this particular example as you could just put a Text("Lazy list text"), it could be a good opportunity to practice this pattern, as it's frequently used in other snippets and real-world scenarios.

Would you be open to giving it a try? I'm happy to provide guidance and support if you need it.

Something like a dummy class like this would match this fake class:

data class Message(sender: String, text: String)

Copy link
Contributor Author

@thedmail thedmail Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure--thank you for helping me learn!!

There's actually a reason why I didn't go ahead and create a data class as you're suggesting. What has me a little mixed-up are these lines:

lazyPagingItems = pager.flow.collectAsLazyPagingItems()

message = lazyPagingItems[index]

So I don't see how I can make message be an object of a new data class (such as I'd create) when it's already a variable set equal of LazyPagingItems type.

This was the complexity that stopped me from just defining my own class, and instead had me resort to commenting.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed it for you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tyvm

Copy link
Collaborator

@riggaroo riggaroo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncomment the Text composables.

thedmail and others added 5 commits September 23, 2024 10:46
…ad-list

# Conflicts:
#	compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt
# Conflicts:
#	compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt
@thedmail thedmail merged commit 9736dd8 into main Sep 30, 2024
5 checks passed
@riggaroo riggaroo deleted the lazily-load-list branch October 2, 2024 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants