Skip to content

Instantly share code, notes, and snippets.

Avatar
🤪

Sebastian Sellmair sellmair

🤪
View GitHub Profile
View A_KN_1.kt
interface LoginViewModel {
/* Inputs */
val userName: Subject<String>
val password: Subject<String>
val passwordRepetition: Subject<String>
val login: Trigger
/* Outputs */
View helpmeplease.js
if (typeof kotlin === 'undefined') {
throw new Error("Error loading module 'output'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'output'.");
}
var output = function (_, Kotlin) {
'use strict';
var throwUPAE = Kotlin.throwUPAE;
var Unit = Kotlin.kotlin.Unit;
var IllegalStateException_init = Kotlin.kotlin.IllegalStateException_init;
var toString = Kotlin.toString;
var println = Kotlin.kotlin.io.println_s8jyv4$;
View Disposing on Android 3.kt
class MainActivity : AppCompatActivity() {
private lateinit var textView: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
textView = findViewById(R.id.text_view)
}
@sellmair
sellmair / Disposing on Android 2.kt
Created Sep 30, 2018
Disposing on Android 2.kt
View Disposing on Android 2.kt
class MyActivity: AppCompatActivity() {
private val lifecycleProvider = AndroidLifecycle.createLifecycleProvider(::getLifecycle)
fun onCreate() {
super.onCreate()
fetchData()
.flatMap(::prepareData)
.compose(lifecycleProvider.bindToLifecycle())
@sellmair
sellmair / Disposing on Android 1.kt
Last active Oct 1, 2018
Disposing on Android 1
View Disposing on Android 1.kt
class MyActivity {
var fetchDataDisposable: Disposable? = null
/* ... */
fun onCreate() {
super.onCreate()
/* stuff */
View CbI-compose2.kt
val patternDetector: PatternDetector = (TrendDownPatternDetector().combineWithoutOverlap(TrendUpPatternDetector()))
.combine(CheatDayPatternDetector().combineWithoutOverlap(SelfLyingPatternDetector())
.combine(DietPatternDetector())
.combine(MotivationBoostPatternDetector())
.combine(...)
...
View PatternDetector+combineWithoutOverlap.kt
fun PatternDetector.combineWithoutOverlap(other: PatternDetector): PatternDetector {
return OverlapFreePatternConnector(this, other)
}
View CbI-OverlapFreePatternDetectorConnector.kt
class OverlapFreePatternDetectorConenctor (
private val first: PatternDetector,
private val second: PatternDetector): PatternDetector {
override fun findPatterns(data: List<Weight>): List<Pattern> {
val firstPatterns = first(data)
val secondPatterns = second(data)
val overlaps = overlaps(firstPatterns, secondPatterns)
View CbI-compose1.kt
val patternDetector: PatternDetector = TrendDownPatternDetector()
.combine(TrendUpPatternDetector())
.combine(CheatDayPatternDetector())
.combine(DietPatternDetector())
.combine(SelfLyingPatternDetector())
.combine(MotivationBoostPatternDetector())
.combine(...)
...
View CbI-PatternDetector+combine.kt
fun PatternDetector.combine(other: PatternDetector): PatternDetector {
return PatternDetectorConnector(this, other)
}
You can’t perform that action at this time.