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

Transition at RxJava 1.x to 2.x

Transition at RxJava 1.x to 2.x

第2回スタートアップAndroid勉強会
https://connpass.com/event/48090/

Ryutaro Miyashita

February 01, 2017
Tweet

More Decks by Ryutaro Miyashita

Other Decks in Technology

Transcript

  1. 5SBOTJUJPOBU3Y+BWBYUPY
    3Y+BWBYַ׵3Y+BWBYפך獳遤

    View full-size slide

  2. 3ZVUBSP.JZBTIJUB
    $IBU8PSL !SZVHPP@

    View full-size slide

  3. 3Y+BWB
    3FBDUJWF&YUFOTJPOTGPSUIF+7.
    "OESPJEꟚ涪ַ׵鋅גծ葿ղדֹ׷
    ؝ؙٖءّٝ乼⡲
    "TZOD5BTLך➿׻׶
    %BUBCJOEJOH
    +BWB"1*ך➿׻׶
    4USFBN
    0QUJPOBM
    &WFOU#VT

    View full-size slide

  4. 3Y+BWBY
    㸜㹀晛ٔٔ٦أ
    3FBDUJWF4USFBNTך➬圫彊䬿
    ➭ך㹋鄲חכ"LLB4USFBNTהַ
    3Y+BWBYַ׵㢌刿ָ׉ֿ׉ֿ֮׷

    View full-size slide

  5. 3Y+BWBYח獳遤ׅ׷
    (JU)VCך8IBUˏTEJFSFODFJO׾铣׬
    ׮ֻ׮ֻה"1*׾刿倜ׅ׷
    3Y+BWB鸬䵿ٓ؎ـٓٔ׾،حفر٦زׅ׷
    ⹛⡲然钠

    View full-size slide

  6. /POOVMM
    Observable.create(emitter -> {
    emitter.onNext(null); // NPE
    });

    View full-size slide

  7. /POOVMM
    enum Notification { INSTANCE; }
    Observable.create(emitter -> {
    emitter.onNext(Notification.INSTANCE);
    });

    View full-size slide

  8. /POOVMM
    OVMM׾FNJUׅ׷ֿהכדֹזְ
    0CTFSWBCMF7PJEכ0CTFSWBCMF0CKFDUד

    FOVNך⦼׾FNJUׅ׷״ֲח㢌ִ׷
    NBQؔلٖ٦ة٦זודSFUVSOOVMM׍ׯ׏ג׋׵

    ⢽ִל/VMM0CKFDUػة٦ٝד㼎䘔ׅ׷
    -JHIUXFJHIU4USFBN"1*ה穈׫さ׻ׇג

    ⦼׾0QUJPOBMדٓحفׅ׷ך׮葺ְַ׮

    View full-size slide

  9. ,JDLTUBSUFSBOESPJEPTT

    View full-size slide

  10. #BDLQSFTTVSF Y

    List nums; // Huge list
    Observablecreate(emitter -> {
    for (int i : nums) {
    emitter.onNext(i);
    }
    })
    .onBackPressureBuffer()
    .subscribe(i -> { /* ignored */ });

    View full-size slide

  11. #BDLQSFTTVSF Y

    List nums; // Huge list
    Flowablecreate(emitter -> {
    for (int i : nums) {
    emitter.onNext(i);
    }
    }, BackpressureStrategy.BUFFER)
    .subscribe(i -> { /* ignored */ });

    View full-size slide

  12. #BDLQSFTTVSF
    0CTFSWBCMFד#BDLQSFTTVSFכ《׶䪔ִזְ
    'MPXBCMF׾⢪ֲ
    0CTFSWBCMFה'MPXBCMF׾幉㖈ׇׁ׷הֹכ岣䠐
    0CTFSWBCMFUP'MPXBCMF
    'MPXBCMFUP0CTFSWBCMF
    'MPXBCMFח㺔ׇ׋倯ָ#BDLQSFTTVSFח㼎䘔דֹ׉ֲ

    View full-size slide

  13. 4VCKFDU Y

    Subject subject =

    new SerializedSubject(

    PublishSubject.create());

    View full-size slide

  14. 4VCKFDU Y

    Subject subject =

    PublishSubject.create()

    .toSerialized();
    Processor processor =

    PublishProcessor.create()

    .toSerialized();

    View full-size slide

  15. 4VCKFDU
    4FSJBMJ[FE4VCKFDUכOFXדכזֻ

    傀㶷ך4VCKFDUַ׵UP4FSJBMJ[FEًاحسד⡲׷
    4VCKFDUדכ#BDLQSFTTVSFכ《׶䪔ִזְ
    1SPDFTTPS׾⢪ֲ

    View full-size slide

  16. 4DIFEVMFST Y

    .subscribeOn(Schedulers.immediate())

    View full-size slide

  17. 4DIFEVMFST Y

    .subscribeOn(Schedulers.trampoline())

    View full-size slide

  18. 4DIFEVMFST
    4DIFEVMFSTJNNFEJBUFכYדכ㶷㖈׃זְ
    ➿׻׶חUSBNQPMJOF׾⢪ֲ
    5ISFBE-PDBMחُؗ٦؎ؚٝ׃ג鷵如Ⳣ椚

    View full-size slide

  19. 3Y#JOEJOH
    3Y#JOEJOHכ7JFXך؎كٝز׾

    0CTFSWBCMFח㢌䳔׃גֻ׸׷
    ⥋걾ה㸜䗰ך+BLF8IBSUPO⯓欰⡲ㅷ
    植㖈NBTUFSـٓٝثָ3Y+BWBYח

    㼎䘔׃גְ׷ָծ姻䒭ٔٔ٦أָת׌

    View full-size slide

  20. 3Y#JOEJOH
    allprojects {

    repositories {

    maven { url 'https://jitpack.io' }

    }

    }
    compile 'com.github.JakeWharton.RxBinding:rxbinding:71f3a1b'
    CVJMEHSBEMF SPPU

    CVJMEHSBEMF BQQ

    ˟SYCJOEJOHBQQDPNQBUWװSYCJOEJOHTVQQPSUW׮ず圫ךغ٦آّٝ䭷㹀ד0,

    View full-size slide

  21. 3Y+BWBYח獳遤׃ג
    ׮ֻ׮ֻה堣唒涸ח縧ֹ䳔ִגְֻ
    OVMM׾FNJU׃ג׷ה/1&חז׷ךד岣䠐ָ䗳銲
    ずׄせ⵸ך"1*ד׮䮙⹛ָ㢌׻׏ג׷׮ך׮،ٔ
    ⢽ִל0CTFSWBCMFUP-JTUכ4JOHMF׾鵤ׅ
    4JOHMF.BZCF$PNQMFUBCMF׾鵤ׅ㢌刿כ㢳ְ
    8IBUTEJFSFOUJO׾擾铣ׅץ׃
    ㉏겗搀ֻ麊欽דֹגְ׷

    View full-size slide

  22. &OKPZ3Y4USFBN-JGF

    View full-size slide