Hi i couldn't find a <#C1FLMRTJA|kotlin> channel s...
# android
a
Hi i couldn't find a #kotlin channel so asking here
Copy code
override suspend fun saveToDeviceRegistry(req: SaveToDeviceRegistryReq): Flow<RepositoryState<Unit>> =
    flow<RepositoryState<Unit>> {
        searchDeviceRegistryByCategoryId(req.deviceProfile.categoryId)?.let {
            it.categoryName = req.deviceProfile.categoryName
            it.categoryId = req.deviceProfile.categoryId
            it.vendor = req.deviceProfile.vendor
            it.model = req.deviceProfile.model
            it.mac = req.deviceProfile.address
            deviceRegistryBox.put(it)
            emit(RepositoryState.SuccessState(Unit))
        } ?: kotlin.run {
            deviceRegistryBox.put(
                DeviceRegistryEntity(
                    categoryName = req.deviceProfile.categoryName,
                    categoryId = req.deviceProfile.categoryId,
                    vendor = req.deviceProfile.vendor,
                    model = req.deviceProfile.model,
                    mac = req.deviceProfile.address,
                )
            )
            emit(RepositoryState.SuccessState(Unit))
        }
    }.flowOn(dispatcher)
Is there a better syntax sugar for the above code scenario ?
k
This entire slack is about Kotlin. You probably should post this in #getting-started
a
@kenkyee thank you 🙂