Home > Enterprise >  How to use kotlin flow flatMap in Android
How to use kotlin flow flatMap in Android

Time:04-22

In my application I want flatMap operators such as flatMapMerge.
But after write codes show me highlight on flatMapMerge and say add one annotation!
I write below codes :

    private fun myFunction() {
    lifecycleScope.launchWhenCreated {
        flowOf("Nerd", "Subby", "Mord")
            .flatMapMerge { userInfo(it) }
            .collect {
                binding.showInfoText.append("$it \n")
            }
    }
}

Show me below highlight :
enter image description here

When added this annotation : @FlowPreview , then not show this highlight!
But my question is why show this highlight? why I should add this annotation?
What's worked this annotation ?

CodePudding user response:

why show this highlight?

Flow preview has no backward compatibility guarantees, including both binary and source compatibility

why I should add this annotation?

you are accept/agree on the drawback of relying on preview API. In the document they are mentioned , they collecting the feed backs on this.upcoming release they will fix the issue.

refer FlowPreview

  • Related