Upgrade to Pro — share decks privately, control downloads, hide ads and more …

"Bring your Kotlin to Work" Day

"Bring your Kotlin to Work" Day

Guillermo Orellana

September 22, 2017
Tweet

More Decks by Guillermo Orellana

Other Decks in Programming

Transcript

  1. – bringyourdogtoworkday.co.uk “[…] the presence of pets can substantially reduce

    a person’s stress level in the workplace. Increased job satisfaction, team co-operation and morale have all been reported in employees that spend the workday with their pets”
  2. – me “[…] the presence of Kotlin can substantially reduce

    a person’s stress level in the workplace. Increased job satisfaction, team co-operation and morale have all been reported in employees that spend the workday with Kotlin”
  3. class MarketDataViewModel { val compositeDisposable = CompositeDisposable() init { compositeDisposable.add(bindToMarketData())

    } val mapper = TODO() fun bindToMarketData(): Disposable = retrieveMarketData.getStream() .map(mapper) .subscribe() }
  4. class MarketDataViewModel { val compositeDisposable = CompositeDisposable() init { compositeDisposable.add(bindToMarketData())

    } val mapper = TODO() fun bindToMarketData(): Disposable = retrieveMarketData.getStream() .map(mapper) .subscribe() }
  5. class MarketDataViewModel { val compositeDisposable = CompositeDisposable() init { compositeDisposable.add(bindToMarketData())

    } val mapper = TODO() fun bindToMarketData(): Disposable = retrieveMarketData.getStream() .map(mapper) .subscribe() }
  6. class MarketDataViewModel { val compositeDisposable = CompositeDisposable() init { compositeDisposable.add(bindToMarketData())

    } val mapper = TODO() fun bindToMarketData(): Disposable = retrieveMarketData.getStream() .map(mapper) .subscribe() }
  7. class MarketDataViewModel { val compositeDisposable = CompositeDisposable() init { compositeDisposable.add(bindToMarketData())

    } val mapper = TODO() fun bindToMarketData(): Disposable = retrieveMarketData.getStream() .map(mapper) .subscribe() }
  8. class MarketDataViewModel { val compositeDisposable = CompositeDisposable() init { compositeDisposable.add(bindToMarketData())

    } val mapper = TODO() fun bindToMarketData(): Disposable = retrieveMarketData.getStream() .map(mapper) .subscribe() }
  9. class MarketDataViewModel { val compositeDisposable = CompositeDisposable() val mapper =

    TODO() init { compositeDisposable.add(bindToMarketData()) } fun bindToMarketData(): Disposable = retrieveMarketData.getStream() .map(mapper) .subscribe() }
  10. public class Balance { @NonNull private final BalanceType type; private

    final int value; public Balance(@NonNull BalanceType type, int value) { this.type = type; this.value = value; } @NonNull public BalanceType getType() { return type; } public int getValue() { return value;
  11. return type == balance.type; } @Override public int hashCode() {

    int result = type.hashCode(); result = 31 * result + value; return result; } @Override public String toString() { return "Balance{" + "type=" + type + ", value=" + value + '}'; } }
  12. fun fromEntity(e: ModerationEntity) = ModerationModel( header = e.header, body =

    e.message, ctaPrimary = e.ctaPrimary, ctaSecondary = e.ctaSecondary, photos = e.photos )
  13. sealed class BalanceResult { data class Balance( val type: BalanceKind

    = Invalid, val value: Int = 0 ): BalanceResult() object BalanceError: BalanceResult() }
  14. class MarketDataRepository( private val store: ReactiveStore<String, MarketData>, private val marketDataService:

    MarketDataService, private val marketDataMapper: MarketDataMapper) { fun getAllMarketData(): Flowable<Optional<List<MarketData >>> = store.getAll() fun fetchMarketData(): Completable = marketDataService.getMarketPrice() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.computation()) .map(marketDataMapper) .doOnSuccess({ store.replaceAll(it) }) .toCompletable() } }
  15. Inspiration • The Case Against Kotlin - Pinterest Engineering •

    Kotlin for grumpy Java developers - Pinterest Engineering • Kotlin: The Good, The Bad, and The Ugly
  16. Links • Try Kotlin - https://try.kotlinlang.org/ • Kotlin Koans -

    https://try.kotlinlang.org/#/Kotlin%20Koans/ • Kategory - https://github.com/kategory/kategory/ • Kotlinlang Slack - slack.kotlinlang.org
  17. Image credits • Android Studio Logo - Android Open Source

    Project (CCBY) • Renibeni - C. Mclean (Free Domain) • John Charles Dollman - Table d'Hote at a Dogs' Home (Free Domain) • Forbidden - Wikimedia (Free Domain) • 869018 - Pixbay (Free Domain)