Response { val response = Response() val walkingInfoStream = BroadcastChannel<WalkingInfo>(Channel.CONFLATED) val walkingPath = request.walkingInfoFetcher.fetch(request.journeyStartLatLng, request.pickupLatLng) launch { walkingInfoStream.send(walkingPath) } startTrackingLocationAndUpdateWalkingPath(walkingPath, walkingInfoStream) response.walkingInfoStream = walkingInfoStream return response } fun handleWalkingInfo(response: Response) { val stream = response.walkingInfoStream.openSubscription() stream.consume { let { channel -> launch { while (!channel.isClosedForReceive) { channel.receiveOrNull()?.let { showWalkingInfo(it) } } fun handleDeepLink(request: Request) : Response { val response = Response() val walkingInfoStream = BroadcastChannel<WalkingInfo>(Channel.CONFLATED) val walkingPath = request.walkingInfoFetcher.fetch(request.journeyStartLatLng, request.pickupLatLng) launch { walkingInfoStream.send(walkingPath) } startTrackingLocationAndUpdateWalkingPath(walkingPath, walkingInfoStream) response.walkingInfoStream = walkingInfoStream return response } fun handleWalkingInfo(response: Response) { val stream = response.walkingInfoStream.openSubscription() stream.consume { let { channel -> launch { while (!channel.isClosedForReceive) { channel.receiveOrNull()?.let { showWalkingInfo(it) } } } }