Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.
This repository was archived by the owner on Jun 22, 2022. It is now read-only.

flowOf doesn't respect the passed key. #42

@Kasheen

Description

@Kasheen

Summary
I realise this is currently an undocumented feature but I think I've encountered a bug with the flowOf function in DBImpl.

Specifically line 38 doesn't take into account the key that the user passed to the function.

One would expect to only receive flow emissions for the model which relates to the passed key, but instead you get everything for that model type.

Fix Proposal
I think trySend at line 38 needs to be guarded with if (keyFrom(operation.model).equals(key)) { trySend(operation.model) }

Other thoughts
If you want me to provide reproducible code or a pull request for the fix I can do - or perhaps I'm misusing the feature.

It looks like the bug would affect the stateFlowOfId function as well because of the delegated function calls.

My current workaround is just to filter the resulting flow and check if the model's id is the id I actually want.

Ultimately it also seems useful to have a function which makes a flow that takes no key which can then be filtered differently and collected in case a user doesn't want to make a flow per id, but currently passing a key feels like it should filter.

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