Skip to content

Instantly share code, notes, and snippets.

View GuilhE's full-sized avatar

Guilherme Delgado GuilhE

View GitHub Profile
@GuilhE
GuilhE / RxExtensions.kt
Created March 4, 2020 00:43
Helper compose functions for RxKotlin
import android.annotation.SuppressLint
import com.blissapplications.kotlin.core.common.threads.ReactivexThreadSchedulerProvider
import io.reactivex.Completable
import io.reactivex.Single
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
/**
* Examples of usage of this extensions functions:
*
@GuilhE
GuilhE / OperatorExtensionsTest.kt
Last active February 19, 2020 11:28
OperatorExtensions tests with MockK
import io.mockk.clearAllMocks
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.runBlockingTest
import kotlinx.coroutines.test.setMain
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.*
@GuilhE
GuilhE / OperatorExtensions.kt
Last active March 21, 2020 21:30
Extension class to convert ReactiveX operators into Coroutines
import kotlinx.coroutines.*
fun throttleClick(scope: CoroutineScope = CoroutineScope(Dispatchers.Main), clickAction: (Unit) -> Unit): (Unit) -> Unit {
return throttleFirst(1_000, scope, clickAction)
}
/**
* Processes input data and passes the first data to [action] and skips all new data for the next [skipMs].
*/
fun <T> throttleFirst(skipMs: Long = 700L, scope: CoroutineScope = CoroutineScope(Dispatchers.Main), action: (T) -> Unit): (T) -> Unit {
@GuilhE
GuilhE / .gitattributes
Created February 1, 2019 13:49
GitAttributes to use with git-lfs
# Collapse Unity-generated files on GitHub
*.asset linguist-generated
*.mat linguist-generated
*.meta linguist-generated
*.prefab linguist-generated
*.unity linguist-generated
# 3D models
*.3dm filter=lfs diff=lfs merge=lfs -text
*.3ds filter=lfs diff=lfs merge=lfs -text