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

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

6eecc52120fba9d87d982684211182ec?s=47 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 のお話をきいて試してみた内容の紹介をしました。

6eecc52120fba9d87d982684211182ec?s=128

mochico

September 11, 2018
Tweet

Transcript

  1. ,PUMJO'FTU׻ְ׻ְ㜠デ⠓ !NPDIJDP ,PUMJO'FTU׻ְ׻ְ㜠デ⠓

  2. "CPVUNF NPDIJDP!@NPDIJDPO@ "OESPJE+BWB,PUMJO 5FDICPPTUFS䪮遭剅Ⱙ

  3. ,PUMJO'FTUֶ气׸圫ד׃׋

  4. ,PUMJO'FTU ˖ ㅷ䊛דꟚ⪵ ˖ 傈劤ⴱך,PUMJOؕٝؿ؋ٖٝأ ˖ ♧菙⿫⸇罏せ 1FBUJY״׶  ˖

    إحءّٝ-5
  5. IUUQTQIPUPTHPPHMFDPNTIBSF"'2JQ.VY*9**#QG3S@)X8U2VQ*$:+M7$4Z[%NE7C&N(BKZB%Q4"@@K9LTS"H LFZ/E%;I8E)/'75'PE)MQ/#JB$MB9QR29+L/;

  6. None
  7. TUBSUGSPN$POWFSUUP,PUMJO

  8. $POWFSU+BWB'JMFUP,PUMJO'JMF

  9. 㹋ꥷחכו׿ז؝٦سחז׏גְ׷ךַ

  10. %FDPNQJMF

  11. ,PUMJO'FTU ֶׅׅ׭إحءّٝ

  12. չ,PUMJOד何㊣ׅ׷"OESPJE،فٔךㅷ颵պ ֮׿ְׂײֹׁ׿ IUUQTTQFBLFSEFDLDPNZBO[NLPUMJOGFTU ؔـآؙؑز䭷ぢⰅꟌ٥&FDUJWF+BWBזוד䱿׭׵ ׸גְ׷㛙暕ד〳铣䚍ծⱄⵃ欽䚍ך넝ְ؝٦سָ ,PUMJOדוך״ֲח鎉铂➬圫ח《׶Ⰵ׸׵׸ծ ,PUMJOד剅ֻֿהד䖞ֲֿהָדֹ׷ַהְֲֶ鑧

  13. չ,PUMJO׮ֲ♧娄պ 啾峔⛒ׁ׿ IUUQTTQFBLFSEFDLDPNLPCJUPLBCBLPUMJONPV CV ,PUMJOך㘗ח׮ֲ♧娄驎׫鴥׿׌ֶ鑧կ ؙٓأה㘗ך麩ְծ؟ـة؎فהכծ/VMM鏩㺁䚍ծ ♶㢌٥Ⱏ㢌٥⿾㢌

  14. չ,PUMJO،فٔךٔؿ؋ؙةؚٔٝه؎ٝزպ ⚥ꅽ湫➂ׁ׿ IUUQTXXXTMJEFTIBSFOFU3FDSVJU-JGFTUZMF SFGBDUPSJOHQPJOUPGLPUMJOBQQMJDBUJPO ,PUMJO׾⢪׏גٔؿ؋ؙةؚׅٔٝ׷կ

  15. չ)PXUP5FTU4FSWFSTJEF,PUMJOպ ꈿ加⨳㣕ׁ׿٥⵸⾱猕䗗ׁ׿ IUUQTTQFBLFSEFDLDPNNBFIBSJOIPXUPUFTU TFSWFSTJEFLPUMJOOVNCFSLPUMJOGFTU 4FSWFS4JEFד6OJUذأزךٓ؎ـٓٔכׄ׭TQSJOHؿ ٖ٦يٙ٦ؙח屟׏׋剅ֹ倯ծ%#ذأزך⸬桦⻉ז וկ ⵸⼱ךٓ؎ـٓٔ稱➜כ"OESPJEד׮剣欽կ

  16. չ,PUMJO؝ٕ٦ثٝ׾椚鍑׃״ֲպ Ⱂ加⤥䎢ׁ׿ IUUQTTQFBLFSEFDLDPNTZTZBHJLPUMJO LPSVUJOXPMJKJFTJZPV +BWBדכأذ٦زوءٝה׃ג㹋遤ׁ׸׷ֿהתד 鍑铡׃׋,PUMJO؝ٕ٦ثٝך寸㹀晛

  17. չ,PUMJOMJOUFSպ ꆏ㹧䡞⛒➜ׁ׿ IUUQTTQFBLFSEFDLDPNLHNZTIJOLPUMJOMJOUFS LUMJOU EFUFLU BOESPJEMJOUך暴䗙ծ鏣㹀ծؕأةي ٕ٦ٕך㼪Ⰵחאְג鍑铡

  18. չ)PXUP,POUSJCVUF W+1 պ 熖頺⢕Ⱙׁ׿ IUUQTQIPUPTHPPHMFDPNTIBSF "'2JQ/B:@+-(28#'HT.MG(G N26U[R'4MNI%GE'8(NTB$4F)P*PDOH LFZC63%E9#:56E%EM7%/8:U5%I#3['KCO2-7M;3KM3 ,PUMJO׉ך׮ךחفؙٕٔ׾鷏׷$POUSJCVUFׅ׷,POUSJCVUF ך➬倯׾鑫׃ֻ铡僇կ

    ֿך酅ך-5㣐⠓דז׿ה➂׮ך涫㠡罏ָTIJSBKJׁ׿ח侄׻׏׋ז ו鎉⿹׃גְ׋կ
  19. չ,PUMJOד䠥ד׷.JDSPTFSWJDFTպ TUPSNDBUׁ׿ IUUQTTQFBLFSEFDLDPNTUPSNDBULPUMJOGFTU 㹋騧涸זغحؙؒٝس,PUMJO鍑铡

  20. וךإحءّٝ׮ֶ׮׃׹ְךד׫ג׫גֻ׌ְׁ

  21. ©2018 Lang-8 Inc. ALL Rights Reserved. ,PUMJO'FTU 5PTIJIJSP:BHJ ,PUMJOίϧʔνϯΛ ཧղ͠Α͏

    IUUQTTQFBLFSEFDLDPNTZTZBHJLPUMJOLPSVUJOXPMJKJFTJZPV
  22. $PSPVUJOFהכ ˖ Ⳣ椚ך鷿⚥ד♧儗⨡姺ָ〳腉 ˖ ⴽךأٖحسדⱄꟚָ〳腉 ˖ ⚥倖٥ⱄꟚך֮׷؝٦سꬊず劍Ⳣ椚זו׾ءٝ فٕח剅ֽ׷ ˖ 3Y+BWBהכ㹋植׃׋ְֿהָ殯ז׷

  23. 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) } ˞ٖࣅίʔυͰ͢
  24. $PSPVUJOFדֹ׉ֲז孡ָ׃גֹ׋

  25. וַֿ׵㨣׭׸לְְ׿׌׹ֲ

  26. 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΋͋ΔΑ
  27. USZ BOESPJEDPSPVUJOFT

  28. None
  29. 橆㞮圓眠 kotlin_version = ‘1.2.61’ kotlin { experimental { coroutines 'enable'

    } } implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core: 0.25.3'
  30. 橆㞮圓眠 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'
  31. BOESPJEDPSPVUJOFT IUUQTHJUIVCDPNQEWSJF[FBOESPJEDPSPVUJOFT

  32. 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() } } } }
  33. PO"DUJWJUZ3FTVMU launch(UI) { val result = activityResult(requestIntent) if (result.isOk) {

    // ok val data: Intent? = result.flatMap() setResult(RESULT_OK, data) finish() } else { // ng } }
  34. USZBOESPJEDPSPVUJOFT׃ג׫׋䠬䟝 ˖ ׅ׀ֻءٝفٕ ˖ ؙٔؒأزהٖأهٝأָずׄ㜥䨽חתהת׷ךד 铣׫װְׅ ˖ 3Y+BWBך縧ֹ䳔ִ״׶䕦갟眔㔲ָ㼰זְ ˖ 㸣Ⰻח傊䒭ה⢘欽〳腉

  35. 3Y+BWB׾⢪׏גְ׷傀㶷،فٔח ,PUMJO$PSPVUJOFT׾㼪Ⰵ׃״ֲ IUUQTRJJUBDPNUBLBIJSPNJUFNTBDBCDEEF

  36. USZBOESPJEDPSPVUJOFT׃ג׫׋䠬䟝 ˖ DPSPVUJOF荈⡤ָת׌♧䘔FYQFSJNFOUBM ˖ BOESPJEDPSPVUJOF׮FYQFSJNFOUBM ˖ فٗتؙزפך㼪Ⰵכ荈䊹顑⟣ד

  37. &OKPZ,PUMJO

  38. SFG ˖ (FUUJOHTUBSUFEXJUI"OESPJEBOE,PUMJO,PUMJO 1SPHSBNNJOH-BOHVBHFIUUQTLPUMJOMBOHPSH EPDTUVUPSJBMTLPUMJOBOESPJEIUNM ˖ (FU4UBSUFEXJUI,PUMJOPO"OESPJE]"OESPJE %FWFMPQFSTIUUQTEFWFMPQFSBOESPJEDPNLPUMJO HFUTUBSUFE ˖

    <,PUMJO؎ٝ٥،ؙءّٝ]و؎شؽـحؙأ> IUUQT CPPLNZOBWJKQFDQSPEVDUTEFUBJMJE