Skip to content

A bunch of tiny extensions to make Android development easier. Enjoy the sugar!

License

Notifications You must be signed in to change notification settings

asappinc/churros

Repository files navigation

CircleCI Download

Churros

This is a humble library dedicated to making the life of developers easier.

Installation

Be sure to have JCenter in the base gradle file.

allprojects {
    repositories {
        jcenter()
    }
}

Then it's a matter of adding the dependency.

dependencies {
    // Churros
    implementation "com.asapp.churros:churros:0.2.0"
}

Things we have

runIf

    val okHttpClient = OkHttpClient.Builder()
        .addInterceptor(interceptor)
        .runIf(isVerbose) {
            val loggingInterceptor =
                HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)

            addNetworkInterceptor(loggingInterceptor)
        }
        .build()

exhaustive

This code will work happily.

    enum class Snack {
        HUMUS, CHIPS, GUACAMOLE
    }
    val today = GUACAMOLE

    when (today) {
        HUMUS -> getPita()
        CHIPS -> buyGuacamole()
    }

This code will complain that you missed thinking about Guacamole

    enum class Snack {
        HUMMUS, CHIPS, GUACAMOLE
    }
    val today = GUACAMOLE

    when (today) {
        HUMMUS -> getPita()
        CHIPS -> buyGuacamole()
    }
    .exhaustive()

Context.toast

    activity.toast(R.string.auth_error)

Single<List>.flatMapList

        fun getAccountInDB(id: Int): Single<Account> = Single.just(Account(id))
        fun getItemsFromNetwork(): Single<List<Int>> = Single.just(listOf(101, 42, 3))

        val result: Single<List<Account>> = getItemsFromNetwork()
            .flatMapList { getAccountInDB(it) }

About

A bunch of tiny extensions to make Android development easier. Enjoy the sugar!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages