Skip to content

Instantly share code, notes, and snippets.


Vladimir Mironov nsk-mironov

  • Moscow, Russia
View GitHub Profile
View LithoDsl.kt
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.Row
import com.facebook.litho.fresco.FrescoImage
import com.facebook.litho.sections.widget.RecyclerCollectionComponent
import com.facebook.litho.widget.Card
import com.facebook.litho.widget.CardClip
import com.facebook.litho.widget.EditText
import com.facebook.litho.widget.EmptyComponent
View BaseObservableMap.kt
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.Observer
import io.reactivex.internal.fuseable.HasUpstreamObservableSource
import io.reactivex.internal.fuseable.QueueFuseable
import io.reactivex.internal.observers.BasicFuseableObserver
abstract class BaseObservableMap<T : Any, U : Any> protected constructor(private val source: ObservableSource<T>) : Observable<U>(), HasUpstreamObservableSource<T> {
override fun source(): ObservableSource<T> {
return source
nsk-mironov / AccountViewModel.kt
Created Apr 11, 2016
Databinding with DelegatedProperties
View AccountViewModel.kt
class AccountViewModel : ObservableModel by ObservableModelDelegate() {
@get:Bindable var name by property<CharSequence>("",
@get:Bindable var authenticated by property(false, BR.authenticated)
@get:Bindable var avatar by property("", BR.avatar)
View References.kt
final class com/github/vmironov/MainKt$main$first$1 extends kotlin/jvm/internal/FunctionReference implements kotlin/jvm/functions/Function2 {
// access flags 0x1041
public synthetic bridge invoke(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
CHECKCAST com/github/vmironov/A
CHECKCAST java/lang/Number
INVOKEVIRTUAL java/lang/Number.intValue ()I
INVOKEVIRTUAL com/github/vmironov/MainKt$main$first$1.invoke (Lcom/github/vmironov/A;I)I
View Reflection.kt
package com.github.vmironov
import kotlin.reflect.jvm.internal.impl.serialization.ClassData
import kotlin.reflect.jvm.internal.impl.serialization.Flags
import kotlin.reflect.jvm.internal.impl.serialization.ProtoBuf
import kotlin.reflect.jvm.internal.impl.serialization.jvm.JvmProtoBufUtil
data class Foo(val foo: String)
data class Bar(val bar: String)
nsk-mironov /
Last active Dec 25, 2017
Delegated properties

Delegated properties is a really nice feature of Kotlin and we are using them a lot in our code base. The entire project contains more than 500 delegated properties. Unfortunatelly, each property compiles to a class with 6 extra methods. While this can be fine if you're running on JVM, this is absolutely unacceptable in case you're targeting Android.

For example, the following class produces 2 more classes, Delegate$bar$1 and Delegate$foo$1:

public class Delegate(private val values: Map<String, Any>) {
  public val bar: String by values
  public val foo: String by values
public class StackOverflow {
public static void main(String[] args) {
final Observable<Integer> firstObs = Observable.just(1, 2, 3, 4, 5);
final Observable<Integer> secondObs = Observable.just(2, 4, 6);
final Observable<Integer> result = secondObs.toList().flatMap(new Func1<List<Integer>, Observable<Integer>>() {
public Observable<Integer> call(final List<Integer> ignore) {
return firstObs.filter(new Func1<Integer, Boolean>() {
public final class OperatorThrottleList<T> implements Operator<T, List<T>> {
private final Scheduler scheduler;
private final long interval;
public OperatorThrottleList(final long interval, final TimeUnit unit, final Scheduler scheduler) {
this.interval = unit.toMillis(interval);
this.scheduler = scheduler;
View gist:e13fe46938bf887f174a
public class Main {
public static void main(final String[] args) throws Exception {
Observable.from(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12))
.groupBy(item -> item % 4)
.filter(integers -> integers.size() > 2)
.subscribe(result -> {
System.out.printf("%d results %s%n", result.size(), result);
You can’t perform that action at this time.