An example related to question on Twitter https://twitter.com/drewdaraabrams/status/1359933543619547137
Try curl https://entreprise.data.gouv.fr/api/sirene/v1/full_text/MONTPELLIERAIN
Among result, look at
"total_results": 161,
/* | |
* Copyright 2023 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* https://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
/* ----------------------------------------- Activity ------------------------------------------ */ | |
/* make sure you have at least 'androidx.activity:activity-ktx:1.6.0-rc01' at your dependencies | |
(just to let you know this dependency is not stable yet ) | |
*/ | |
implementation 'androidx.activity:activity-ktx:1.6.0-rc01' | |
fun AppCompatActivity.onBackPressed(isEnabled: Boolean, callback: () -> Unit) { | |
onBackPressedDispatcher.addCallback(this, |
fun <T> ViewModel<*>.savedMutableStateFlow( | |
initialValue: T, | |
key: String? = null, | |
): ReadOnlyProperty<ViewModel<*>, MutableStateFlow<T>> { | |
var mutableStateFlow: MutableStateFlow<T>? = null | |
return ReadOnlyProperty { _, property -> | |
if (mutableStateFlow != null) { | |
return@ReadOnlyProperty mutableStateFlow!! | |
} |
import androidx.compose.animation.core.* | |
import androidx.compose.foundation.background | |
import androidx.compose.foundation.layout.* | |
import androidx.compose.foundation.shape.CircleShape | |
import androidx.compose.material.MaterialTheme | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.getValue | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier |
/** | |
* Starts collecting a flow when the lifecycle is started, and **cancels** the collection on stop. | |
* This is different from `lifecycleScope.launchWhenStarted { flow.collect{...} }`, in which case | |
* the coroutine is just suspended on stop. | |
*/ | |
inline fun <reified T> Flow<T>.collectWhileStarted( | |
lifecycleOwner: LifecycleOwner, | |
noinline action: suspend (T) -> Unit | |
) { | |
object : DefaultLifecycleObserver { |
An example related to question on Twitter https://twitter.com/drewdaraabrams/status/1359933543619547137
Try curl https://entreprise.data.gouv.fr/api/sirene/v1/full_text/MONTPELLIERAIN
Among result, look at
"total_results": 161,
import android.Manifest.permission.ACCESS_COARSE_LOCATION | |
import android.content.Context | |
import android.content.Intent | |
import android.net.Uri | |
import android.os.Bundle | |
import android.provider.Settings | |
import androidx.activity.ComponentActivity | |
import androidx.activity.result.contract.ActivityResultContracts.RequestPermission | |
import androidx.appcompat.app.AppCompatActivity | |
import kotlinx.android.synthetic.main.activity_main.* |
import androidx.lifecycle.get | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.ViewModelProvider | |
import androidx.lifecycle.ViewModelStore | |
import androidx.lifecycle.ViewModelStoreOwner | |
/** | |
* Returns a property delegate to access the wrapped value, which will be retained for the | |
* duration of the lifecycle of this [ViewModelStoreOwner]. | |
* |
Or open the terminal and try this script:
flutter clean
package by.krossovochkin.testflow | |
import io.reactivex.Observable | |
import io.reactivex.exceptions.CompositeException | |
import io.reactivex.schedulers.Schedulers | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.flow.* | |
import org.junit.Test | |
import java.util.concurrent.CopyOnWriteArrayList | |
import java.util.concurrent.CountDownLatch |