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

Kotlin Fest 2018 わいわい報告会 / mochicoroutines

mochico
September 11, 2018

Kotlin Fest 2018 わいわい報告会 / mochicoroutines

Kotlin Fest 2018 わいわい報告会 - connpass : https://connpass.com/event/100752/
各セッションの紹介と、Kotlin コルーチンを 理解しよう - Speaker Deck : https://speakerdeck.com/sys1yagi/kotlin-korutinwo-li-jie-siyou のお話をきいて試してみた内容の紹介をしました。

mochico

September 11, 2018
Tweet

More Decks by mochico

Other Decks in Technology

Transcript

  1. IUUQTTQFBLFSEFDLDPNTZTZBHJLPUMJOLPSVUJOXPMJKJFTJZPV ©2018 Lang-8 Inc. ALL Rights Reserved. ܧଓঢ়گΛ༰қʹॻ͘ ίϧʔνϯ BTZODBXBJU

    fun loadProfile(id: Int) { getProfile(token) { profile -> showProgile(profile) } } ίʔϧόοΫελΠϧ fun loadProfile(id: Int) { val profile = getProfile(id).await() showProfile(profile) } ˞ٖࣅίʔυͰ͢
  2. IUUQTTQFBLFSEFDLDPNTZTZBHJLPUMJOLPSVUJOXPMJKJFTJZPV ©2018 Lang-8 Inc. ALL Rights Reserved. PO"DUJWJUZ3FTVMUΛTVTQFOE launch(UI) {

    val result = activityResult(intent) if (result.isOk) { // ok val data: Intent? = result.flatMap() } else { // ng } } IUUQTHJUIVCDPNQEWSJF[FBOESPJEDPSPVUJOFT BOESPJEDPSPVUJOFTͱ͍͏αʔυύʔςΟϥΠϒϥϦ͕ ఏڙɻSFRVFTU1FSNJTTJPO΋͋ΔΑ
  3. 橆㞮圓眠 kotlin_version = ‘1.2.61’ kotlin { experimental { coroutines 'enable'

    } } implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core: 0.25.3'
  4. 橆㞮圓眠 kotlin_version = ‘1.2.61’ kotlin { experimental { coroutines 'enable'

    } } implementation ‘org.jetbrains.kotlinx:kotlinx-coroutines-core:0.25.3' implementation 'net.devrieze:android-coroutines:0.7.0'
  5. PO"DUJWJUZ3FTVMU startActivityForResult( requestIntent, REQUEST_CODE) override fun onActivityResult(requestCode: Int, resultCode: Int,

    data: Intent?) { super.onActivityResult(requestCode, resultCode, data) when (requestCode) { REQUEST_CODE -> { if (resultCode == Activity.RESULT_OK) { data ?: return setResult(RESULT_OK, data) finish() } } } }
  6. PO"DUJWJUZ3FTVMU launch(UI) { val result = activityResult(requestIntent) if (result.isOk) {

    // ok val data: Intent? = result.flatMap() setResult(RESULT_OK, data) finish() } else { // ng } }