get an error about the suspend function when using the coroutine

Hi you are calling suspend function inside observe lambda.

Change the order like this:

   viewModel.tickets.observe(viewLifecycleOwner,  { data ->
           lifecycleScope.launchWhenCreated{
                data?.let { list ->
                    adapter.submitData(list)
                }
            })
    }

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top