Skip to content

How do you know when the watches field has been populated? #9

@matejdro

Description

@matejdro

Currently watches field is backed by a MutableStateFlow that starts with an emptyList() and then, eventually, this field will get populated from the database asynchronously.

This presents a problem: there is no way to distinguish between "watches have been loaded and user's watch list is empty" vs "watch list is yet to be loaded" states.

My use case for this is to, on phone boot, only start the app background service if there are any enabled watches to actually connect. Since this is on startup, I would get an empty list immediately and then after some undetermined time, list would get populated.

Ideally, this flow would be modified to not emit anything until the list is loaded, but I'm not sure how much would that break things on your side. As an alternative, we can add a watchesLoaded: Flow<Boolean> field to the Watches. What do you think? I can submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions