https://kotlinlang.org logo
#getting-started
Title
# getting-started
m

mgrazianodecastro

02/16/2023, 12:18 PM
I need to trigger a infinite loop in a repository class, delayed by some time, contained in a suspend call. How can I achieve that without blocking execution flow? I'm testing the flow, so I'm under
runTest
testScope coroutine.
it seems that
CoroutineScope(...).launch{}
is the way to go
p

phldavies

02/16/2023, 2:54 PM
You may want to ensure the
CoroutineScope
follows the lifetime of the repository. I.e. provide a
close
method on the repository that will
cancel
the scope.
👀 1
m

mgrazianodecastro

02/16/2023, 2:56 PM
that's a very good point. I need to save myself from memory leak!