I'd like to store action and to run when i can run...
# coroutines
g
I'd like to store action and to run when i can run form first and last. I ' m using a channel but it doesn't.
Copy code
var channelScope = CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO> + Job())
 val channel : Channel<TLocalEntityInterface> = Channel<TLocalEntityInterface>()

override suspend fun send( elem: TLocalEntityInterface) {
     channelScope.launch {
         channel.send(elem)
     }
 }


 override suspend  fun startChannel( ) {
         for (element in channel) {
             var entity = channel.receive()
             logRepository.tag("sync").d("sync: startChannel  stampo un elmentot ${entity}".toUpperCase())

             when(entity){
                 is MyType -> {
                    Timber.tag("sync").d(": nome  ${entity.name}")
                 }
             }
         }

 }
iit doesn/t work
p
From what coroutine you call startChannel?
g
i used channelScope but it didn.t work
p
You can try
channel.consumeEach
g
i need to store data and after a trigger flag comsume data
p
And what is failing specifically? The channel.receive() never returns?
g
a monent i try again