Slide 1

Slide 1 text

SWORD ART COMBINE - ΞϦγθʔγϣϯ- iOS Functional Architecture ษڧձ 2020.10.25 @yiamjo

Slide 2

Slide 2 text

͜ͷεϥΠυʹ͸2020೥य़Ն์ૹͷ ΞχϝSAOΞϦγθʔγϣϯฤͷ ωλόϨؚ͕·Ε·͢

Slide 3

Slide 3 text

͋ͱͰݟΑ͏ͱࢥͬͯΔํ͸ ໨ΛͭΉ͍͔ͬͯͨͩ͘ ӾཡΛ͝தࢭ͍ͩ͘͞

Slide 4

Slide 4 text

Ξχϝ൛͚ͩͰ͍͍ΜͰ·ͣSAOΛݟ ͔ͯΒ͜ͷࢿྉΛݟ͍ͯͩ͘͞

Slide 5

Slide 5 text

ͪΌΜͱΞχϝ൛ݟ·ͨ͠ʁ ͋ɺ͍ͭͰʹ ͍ͭͰʹܶ৔൛΋͋ΔΜͰΞϦγθʔ γϣϯฤͷલʹݟ·ͨ͠ʁ

Slide 6

Slide 6 text

͍͍ͬͨɺͳͥͦΜͳ͜ͱΛ…

Slide 7

Slide 7 text

͍΍ɺࣗ෼ͷ޷͖ʹεϥΠυ࡞ͬͨ΄ ͏͕ḿΔ͔Β…

Slide 8

Slide 8 text

ΞΫηϧϫʔϧυͷํ΋ݟͨ΄͏͕͍ ͍Ͱ͔͢ʁ

Slide 9

Slide 9 text

ͳΔ΄Ͳ ΞΫηϧϫʔϧυͷํ͸ະࢹௌͰ͔· ͍·ͤΜ

Slide 10

Slide 10 text

Ͱ͸͔͜͜Β͸ Ξχϝ൛SAO͓Αͼܶ৔Ξχϝ൛Λݟ ͨͱ͍͏͜ͱͰਐΊ·͢

Slide 11

Slide 11 text

• લฤ: TCAͰ࢖ΘΕ͍ͯΔ pointfreeco/combine-schedulers • https://github.com/pointfreeco/combine-schedulers • RxSwiftͱͷൺֱ • ޙฤ: ͦ΋ͦ΋CombineͰͷSchedulerͷ໾ׂ΍ಈ࡞ • pointfreeco/combine-schedulers ͕Ͳ͏΍ͬͯΔͷ͔ ࠓ೔࿩͢͜ͱ

Slide 12

Slide 12 text

TCAͰ࢖ΘΕ͍ͯΔ pointfreeco/combine-schedulers ʹ͍ͭͯ લ൒

Slide 13

Slide 13 text

TCAͰ͸ReducerͷςετͰ࢖ΘΕΔ

Slide 14

Slide 14 text

Reducerͷςετͷྫ ps://github.com/pointfreeco/swift-composable-architecture/blob/0.8.0/Examples/Search/Search/SearchView.swift Examples/Search/SearchView

Slide 15

Slide 15 text

Reducerͷςετͷྫ ps://github.com/pointfreeco/swift-composable-architecture/blob/0.8.0/Examples/Search/Search/SearchView.swift https://github.com/pointfreeco/swift-composable-architecture/blob/0.8.0/Examples/Search/SearchTests/SearchTests.swif Examples/Search/SearchView

Slide 16

Slide 16 text

೚ҙʹ࣌ؒΛਐΊɺ EffectΛଈ࣮࣌ߦ͍ͤͯ͞Δ

Slide 17

Slide 17 text

Πϝʔδ: ಈըϓϨΠϠʔ

Slide 18

Slide 18 text

Πϝʔδ: ಈըϓϨΠϠʔ

Slide 19

Slide 19 text

࣍ʹԿ͕͋Δ͔ͱ͍͏ͷ͕Θ͔͍ͬͯͯɺ ͦͷλΠϛϯά·Ͱ࣌ؒΛਐΊΔ͜ͱ͕Ͱ͖ΔͷͰ ςετ࣮ߦ࣌ʹ࣮࣌ؒͷܦա͸ඞཁ͕ͳ͍ɻ Πϝʔδ: ಈըϓϨΠϠʔ

Slide 20

Slide 20 text

ൺֱͷͨΊʹRxSwiftͷ࿩Λग़͢Αʂ

Slide 21

Slide 21 text

RxSwift ͷ TestScheduler ͸ ࣌ؒΛԾ૝తʹѻ͏͜ͱͰ ςετίʔυΛಡΈ΍ͯ͘͢͠Δ

Slide 22

Slide 22 text

ղ૾౓ͱ͍͏֓೦͕͋Δ • Ծ૝࣌ؒ = ݱ࣮࣌ؒ / ղ૾౓ • ۩ମྫʢղ૾౓Λ0.1ͱͨ͠৔߹ʣ • Ծ૝࣌ؒ10 = ݱ࣮࣌ؒ1ඵ / ղ૾౓0.1 • Ծ૝࣌ؒ3 = ݱ࣮࣌ؒ0.3 / ղ૾౓0.1 ςετΛ࣮ߦ͢ΔλΠϛϯάΛݱ࣮࣌ؒͰࢦఆ͢ΔͷͰ͸ͳ͘ɺ Ծ૝࣌ؒͰࢦఆ͢Δ͜ͱͰςετ࣮ߦΛݱ࣮࣌ؒʹґଘͤ͞ͳ͍Α͏ʹͰ͖͍ͯΔɻ

Slide 23

Slide 23 text

ݱ࣮ͷ࣌ؒͰͪΜͨΒ࣮ߦΛ ଴ͭͷͰ͸ͳ͘ɺԾ૝࣌ؒͷதͰ ΠϕϯτΛॱ࣍ॲཧ͍ͯ͘͠… ʢRxSwift Ծ૝࣌ؒͷܦա͕࣮࣌ؒࡍʹͲ͏͍͏εϐʔυ͔͸෼͔Βͳ͍΋ͷͷʣ ͜Ε͸Կ͔ ͜͜Ζ͋ͨΓ͋Γ·͢ΑͶ….ʂ

Slide 24

Slide 24 text

Πϝʔδ: SAO ΞϦγθʔγϣϯฤͷԾ૝ੈքʮΞϯμʔϫʔϧυʯ Ҿ༻: https://sao-alicization.net/ SAOݱ࣮ੈք SAOԾ૝ੈքʮΞϯμʔϫʔϧυʯ

Slide 25

Slide 25 text

ݱ࣮ੈքͷ࣌ؒʹ͍ͨͯ͠ഒ཰Λ͔͚ΒΕͨ ࣌ؒʹΑͬͯՃ଎ͯ͠ੈքΛߏங͍ͯ͠Δ Πϝʔδ: SAO ΞϦγθʔγϣϯฤͷԾ૝ੈքʮΞϯμʔϫʔϧυʯ Ҿ༻: https://sao-alicization.net/ SAOݱ࣮ੈք SAOԾ૝ੈքʮΞϯμʔϫʔϧυʯ

Slide 26

Slide 26 text

ͱ͍͏Θ͚Ͱ RxSwift ͱൺֱͭͭͦ͠ ͷҧ͍Λ੔ཧ͢Δͱ

Slide 27

Slide 27 text

RxSwift ͷεέδϡʔϥ͸ SAO ΞϯμʔϫʔϧυతʹԾ૝࣌ؒͱͯ͠ѻ͏ɻ CombineScheduler ͸ ϝσΟΞϓϨΠϠʔతʹ࣌ؒΛ ੍ޚͯ͠ඈ͹͢ɻ

Slide 28

Slide 28 text

༨ஊ

Slide 29

Slide 29 text

SAO ݱ࣮ੈքͷهऀ SAO ݱ࣮ੈքʹϩϘମͰ࿈Εͯ͜ΒΕͨ ΞϯμʔϫʔϧυਓͷΞϦε͞Μ Ҿ༻: https://sao-alicization.net/

Slide 30

Slide 30 text

-> هऀձݟ։͘ΜͳΒ಄֖։͍ͯAIͬͯূ໌ͯ͠ SAO ݱ࣮ੈքͷهऀ SAO ݱ࣮ੈքʹϩϘମͰ࿈Εͯ͜ΒΕͨ ΞϯμʔϫʔϧυਓͷΞϦε͞Μ Ҿ༻: https://sao-alicization.net/

Slide 31

Slide 31 text

-> هऀձݟ։͘ΜͳΒ಄֖։͍ͯAIͬͯূ໌ͯ͠ ͡Ό͋ͦͬͪ΋಄֖։͍ͯਓؒͬͯূ໌ͯ͠ <- SAO ݱ࣮ੈքͷهऀ SAO ݱ࣮ੈքʹϩϘମͰ࿈Εͯ͜ΒΕͨ ΞϯμʔϫʔϧυਓͷΞϦε͞Μ Ҿ༻: https://sao-alicization.net/

Slide 32

Slide 32 text

-> هऀձݟ։͘ΜͳΒ಄֖։͍ͯAIͬͯূ໌ͯ͠ ͡Ό͋ͦͬͪ΋಄֖։͍ͯਓؒͬͯূ໌ͯ͠ <- ΞϯμʔϫʔϧυਓΛ <- ਓ޻෺ݺ͹ΘΓ͚ͯͬ͠Ͳ͞ʙ ͓લΒͷੈքͷͦͷ্ʹ͸ Կ΋ͳ͍ͱݴ͍੾ΕΔΜ͔ʁ ͓લΒͷ૑଄ओ͕͍ͯɺ͓લΒࣗମ ਓ޻తʹͭ͘ΒΕͨΜ͡Όͳ͍ͬͯ ͦ͏͍͏ͷূ໌Ͱ͖Μͷ͔ʙ SAO ݱ࣮ੈքͷهऀ SAO ݱ࣮ੈքʹϩϘମͰ࿈Εͯ͜ΒΕͨ ΞϯμʔϫʔϧυਓͷΞϦε͞Μ Ҿ༻: https://sao-alicization.net/

Slide 33

Slide 33 text

-> هऀձݟ։͘ΜͳΒ಄֖։͍ͯAIͬͯূ໌ͯ͠ ͡Ό͋ͦͬͪ΋಄֖։͍ͯਓؒͬͯূ໌ͯ͠ <- ΞϯμʔϫʔϧυਓΛ <- ਓ޻෺ݺ͹ΘΓ͚ͯͬ͠Ͳ͞ʙ ͓લΒͷੈքͷͦͷ্ʹ͸ Կ΋ͳ͍ͱݴ͍੾ΕΔΜ͔ʁ ͓લΒͷ૑଄ओ͕͍ͯɺ͓લΒࣗମ ਓ޻తʹͭ͘ΒΕͨΜ͡Όͳ͍ͬͯ ͦ͏͍͏ͷূ໌Ͱ͖Μͷ͔ʙ SAO ݱ࣮ੈքͷهऀ SAO ݱ࣮ੈքʹϩϘମͰ࿈Εͯ͜ΒΕͨ ΞϯμʔϫʔϧυਓͷΞϦε͞Μ ΞϯμʔϫʔϧυͰ฻Β͢ੜ໋ମ͸ ࣗ෼͕ͨͪSAOݱ࣮ੈքਓʹΑͬͯਓ޻తʹ ͭ͘ΒΕͨͳΜͯࢥͬͯͳ͍Θ͚ Ҿ༻: https://sao-alicization.net/

Slide 34

Slide 34 text

લ൒ऴΘΓ

Slide 35

Slide 35 text

ޙ൒ ͦ΋ͦ΋CombineͰͷScheduler ͷ໾ׂ΍ಈ࡞

Slide 36

Slide 36 text

• combine-schedulers͕ԿΛ΍ͬͯΔ͔஌Γ͍ͨ • ͦ΋ͦ΋CombineͷSchedulerͱ͸Կͳͷ͔Λઌʹ஌Βͳ͍ͱ͍͚ ͳ͍ • ͦ΋ͦ΋PublisherͱSubscriberͷ΍ΓͱΓ͔Β͓͞Β͍ • Schedulerϓϩτίϧͷϝιου͕ݺ͹ΕΔ͜ͱͷجૅ

Slide 37

Slide 37 text

pointfreeco/combine-schdulers ͕ Ͳ͏΍ͬͯ೚ҙʹ࣌ؒΛ ੍ޚͰ͖Δͷ͔ͷͨΊͷجૅ

Slide 38

Slide 38 text

Schedulerʹؔ͢ΔΑ͋͘Δઆ໌ͷྫ… Scheduler͸ʮUpstreamͷʯʮDownstreamͷʯ ॲཧεϨουΛ੾Γସ͑Δ

Slide 39

Slide 39 text

Schedulerʹؔ͢ΔΑ͋͘Δઆ໌ͷྫ… Scheduler͸ʮUpstreamͷʯʮDownstreamͷʯ ॲཧεϨουΛ੾Γସ͑Δ ͱ͍͏ͷΛਂ۷Γͭͭ͠આ໌Λ͠·͢

Slide 40

Slide 40 text

subscribe(on:)ͱreceive(on:) let cancellable = publisher .flatMap { … } .subscribe(on: DispatchQueue.global()) .map { String($0) } .receive(on: DispatchQueue.main) .sink { print($0) }

Slide 41

Slide 41 text

subscribe(on:)ͱreceive(on:) let cancellable = publisher .flatMap { … } .subscribe(on: DispatchQueue.global()) .map { String($0) } .receive(on: DispatchQueue.main) .sink { print($0) }

Slide 42

Slide 42 text

subscribe(on:)ͱreceive(on:) let cancellable = publisher .flatMap { … } .subscribe(on: DispatchQueue.global()) .map { String($0) } .receive(on: DispatchQueue.main) .sink { print($0) } subscribe(on:)Ͱࢦఆͨ͠εέδϡʔϥʹΑΓɺ UpstreamͱDownstreamεϨου͕੾ΓସΘΔ

Slide 43

Slide 43 text

subscribe(on:)ͱreceive(on:) let cancellable = publisher .flatMap { … } .subscribe(on: DispatchQueue.global()) .map { String($0) } .receive(on: DispatchQueue.main) .sink { print($0) } subscribe(on:)Ͱࢦఆͨ͠εέδϡʔϥʹΑΓɺ UpstreamͱDownstreamεϨου͕੾ΓସΘΔ

Slide 44

Slide 44 text

subscribe(on:)ͱreceive(on:) let cancellable = publisher .flatMap { … } .subscribe(on: DispatchQueue.global()) .map { String($0) } .receive(on: DispatchQueue.main) .sink { print($0) } subscribe(on:)Ͱࢦఆͨ͠εέδϡʔϥʹΑΓɺ UpstreamͱDownstreamεϨου͕੾ΓସΘΔ

Slide 45

Slide 45 text

subscribe(on:)ͱreceive(on:) let cancellable = publisher .flatMap { … } .subscribe(on: DispatchQueue.global()) .map { String($0) } .receive(on: DispatchQueue.main) .sink { print($0) } subscribe(on:)Ͱࢦఆͨ͠εέδϡʔϥʹΑΓɺ UpstreamͱDownstreamεϨου͕੾ΓସΘΔ receive(on:)Ͱࢦఆͨ͠εέδϡʔϥʹΑΓɺ DownstreamͷεϨου͕੾ΓସΘΔ

Slide 46

Slide 46 text

subscribe(on:)ͱreceive(on:) let cancellable = publisher .flatMap { … } .subscribe(on: DispatchQueue.global()) .map { String($0) } .receive(on: DispatchQueue.main) .sink { print($0) } subscribe(on:)Ͱࢦఆͨ͠εέδϡʔϥʹΑΓɺ UpstreamͱDownstreamεϨου͕੾ΓସΘΔ receive(on:)Ͱࢦఆͨ͠εέδϡʔϥʹΑΓɺ DownstreamͷεϨου͕੾ΓସΘΔ subscribe(on:)͸Downstream ʹ΋Өڹ͢Δ

Slide 47

Slide 47 text

ਖ਼֬͞ͷͨΊͷิ଍ • subscribe(on:) • UpstreamͷεϨουΛ੾Γସ͑Δ͕ɺDownstremʹ΋Өڹ͕͋Δ • receive(on:) • DownstreamͷΈεϨουΛ੾Γସ͑Δ

Slide 48

Slide 48 text

ਖ਼֬͞ͷͨΊͷิ଍ • subscribe(on:) • UpstreamͷεϨουΛ੾Γସ͑Δ͕ɺDownstremʹ΋Өڹ͕͋Δ • receive(on:) • DownstreamͷΈεϨουΛ੾Γସ͑Δ ͜ΕΒ͸୯ͳΔϧʔϧͰ͸ͳ͘ɺ ࣮ࡍ͸ཧղ͢Ε͹௚ײͰΘ͔ΔΘ͚Α

Slide 49

Slide 49 text

WWDC19ͷCombineͷηογϣϯ ͜͜ͰSchedulerʹ͍ͭͯͷಈ࡞͕͋ΔͷͰͦΕͰิ଍͢Ε͹ྑͦ͞͏

Slide 50

Slide 50 text

/05& 4VCTDSJQUJPOͷಈ࡞͸೚ҙͷͨΊɺ ͜ͷྫͰ͸͜͏͍͏ಈ࡞Λ ͍ͯ͠Δͱ͍͏ྫͰ͔͠ͳ͍Ͱ͢ɻ

Slide 51

Slide 51 text

/05& 4VCTDSJQUJPOͷಈ࡞͸೚ҙͷͨΊɺ ͜ͷྫͰ͸͜͏͍͏ಈ࡞Λ ͍ͯ͠Δͱ͍͏ྫͰ͔͠ͳ͍Ͱ͢ɻ Publisher͕.subscribe(on: scheduler) ͞Ε͍ͯΕ͹ɺTVCTDSJCF΍SFDFJWF͞Εͨࡍ ࢦఆ͞Εͨ4DIFEVMFSͷϓϩτίϧͷϝιουͰ ॲཧΛ࣮ߦ͢Δ͜ͱͰΩϡʔΛ੾Γସ͑Δɻ ˣ 1VCMJTIFSͷΠϕϯτॲཧٴͼɺͦͷޙͷॲཧ΋ ੾Γସ͑ΒΕͨΩϡʔͰҾ͖ଓ͖࣮ߦ͞ΕΔɻ

Slide 52

Slide 52 text

/05& 4VCTDSJQUJPOͷಈ࡞͸೚ҙͷͨΊɺ ͜ͷྫͰ͸͜͏͍͏ಈ࡞Λ ͍ͯ͠Δͱ͍͏ྫͰ͔͠ͳ͍Ͱ͢ɻ Publisher͕ .receive(on: scheduler) ͞Ε͍ͯΕ͹ɺSFDFJWF࣌ʹ ࢦఆ͞Εͨ4DIFEVMFS͕ ͦͷΩϡʔͰॲཧΛ࣮ߦ͢Δɻ ˣ ͦͷޙͷॲཧ΋ͦͷΩϡʔͰ Ҿ͖ଓ͖࣮ߦ͞ΕΔɻ Publisher͕.subscribe(on: scheduler) ͞Ε͍ͯΕ͹ɺTVCTDSJCF΍SFDFJWF͞Εͨࡍ ࢦఆ͞Εͨ4DIFEVMFSͷϓϩτίϧͷϝιουͰ ॲཧΛ࣮ߦ͢Δ͜ͱͰΩϡʔΛ੾Γସ͑Δɻ ˣ 1VCMJTIFSͷΠϕϯτॲཧٴͼɺͦͷޙͷॲཧ΋ ੾Γସ͑ΒΕͨΩϡʔͰҾ͖ଓ͖࣮ߦ͞ΕΔɻ

Slide 53

Slide 53 text

Schedulerϓϩτίϧͷඞਢϝιου • schedule(options:_:) • schedule(after:tolerance:options:_:) • schedule(after:interval:tolerance:options:_:) https://developer.apple.com/documentation/combine/scheduler

Slide 54

Slide 54 text

Scheduler ͷඞਢϝιου scheduler(options:_:) https://github.com/pointfreeco/combine-schedulers/blob/0.1.2/Sources/CombineSchedulers/TestScheduler.swift var scheduled: [(sequence: UInt, date: SchedulerTimeType, action: () -> Void)] = []

Slide 55

Slide 55 text

ਖ਼֬͞ͷͨΊͷิ଍ -> ཧ۶͕Θ͔ͬͨ͸ͣ • subscribe(on:) • UpstreamͷεϨουΛ੾Γସ͑Δ͕ɺDownstremʹ΋Өڹ͕͋Δ • subscribe͞Εͨࡍ΍request͞Εͨࡍʹಈ࡞͢ΔεέδϡʔϥΛܾΊΔʢ࣮͸΋͏গ͠ ࡉ͔͘Ωϟϯηϧ͞Εͨࡍ΋ͦͷεέδϡʔϥ͕ಈ͘ʣ • receive(on:) • DownstreamͷΈεϨουΛ੾Γସ͑Δ • Subscriber͕receiveͨ͠ࡍʹಈ࡞͢ΔεέδϡʔϥΛܾΊΔ https://developer.apple.com/documentation/combine/publishers/handleevents/subscribe(on:options:)

Slide 56

Slide 56 text

ͳΜͰ͜Μͳ࿩ͯ͠Δ͔

Slide 57

Slide 57 text

pointfreeco/combine-schdulers ͸Ͳ͏΍ͬͯ ࣌ؒΛ੍ޚͯ͠Δ͔ͱ͔ͷ࿩

Slide 58

Slide 58 text

combine-schedulersͷ advance(by:) ͕ԿΛ΍ͬͯΔͷ͔ΛݟͯΈΔ

Slide 59

Slide 59 text

// scheduledऔΓग़ͤͨΒΞΫγϣϯΛ࣮ߦͯ͠࡟আ͓ͯ͘͠ now nextDate finalDate advance(by:)

Slide 60

Slide 60 text

// ݱࡏ͔࣌ؒΒࢦఆ࣌ؒΛਐΊͨ࣌ؒ finalDate // scheduledऔΓग़ͤͨΒΞΫγϣϯΛ࣮ߦͯ͠࡟আ͓ͯ͘͠ now nextDate finalDate advance(by:)

Slide 61

Slide 61 text

// ݱࡏ͔࣌ؒΒࢦఆ࣌ؒΛਐΊͨ࣌ؒ finalDate // ݱࡏ࣌ؒ <= ਐΊͨ࣌ؒͳΒ ͦͷؒϧʔϓʢͭ·Γݱࡏ࣌ؒ͸ਐΊΒΕΔʣ // scheduledऔΓग़ͤͨΒΞΫγϣϯΛ࣮ߦͯ͠࡟আ͓ͯ͘͠ now nextDate finalDate advance(by:)

Slide 62

Slide 62 text

// ݱࡏ͔࣌ؒΒࢦఆ࣌ؒΛਐΊͨ࣌ؒ finalDate // ݱࡏ࣌ؒ <= ਐΊͨ࣌ؒͳΒ ͦͷؒϧʔϓʢͭ·Γݱࡏ࣌ؒ͸ਐΊΒΕΔʣ // scheduledऔΓग़ͤͨΒΞΫγϣϯΛ࣮ߦͯ͠࡟আ͓ͯ͘͠ // ݱࡏ࣌ؒΛਐΊͨ࣌ؒ >= εέδϡʔϧ͞ΕͨΠϕϯτ࣌ؒ now nextDate finalDate advance(by:)

Slide 63

Slide 63 text

// ݱࡏ͔࣌ؒΒࢦఆ࣌ؒΛਐΊͨ࣌ؒ finalDate // ݱࡏ࣌ؒ <= ਐΊͨ࣌ؒͳΒ ͦͷؒϧʔϓʢͭ·Γݱࡏ࣌ؒ͸ਐΊΒΕΔʣ // scheduledऔΓग़ͤͨΒΞΫγϣϯΛ࣮ߦͯ͠࡟আ͓ͯ͘͠ // ݱࡏ࣌ؒΛਐΊͨ࣌ؒ͸ɺ·ͩεέδϡʔϧ͞ΕͨΠϕϯτͷ࣌ؒʹಧ͍ͯͳ͍ͷͰ // ݱࡏ࣌ؒΛਐΊͨ࣌ؒ >= εέδϡʔϧ͞ΕͨΠϕϯτ࣌ؒ now nextDate finalDate advance(by:)

Slide 64

Slide 64 text

// ݱࡏ͔࣌ؒΒࢦఆ࣌ؒΛਐΊͨ࣌ؒ finalDate // ݱࡏ࣌ؒ <= ਐΊͨ࣌ؒͳΒ ͦͷؒϧʔϓʢͭ·Γݱࡏ࣌ؒ͸ਐΊΒΕΔʣ // scheduledऔΓग़ͤͨΒΞΫγϣϯΛ࣮ߦͯ͠࡟আ͓ͯ͘͠ // ݱࡏ࣌ؒΛਐΊͨ࣌ؒ͸ɺ·ͩεέδϡʔϧ͞ΕͨΠϕϯτͷ࣌ؒʹಧ͍ͯͳ͍ͷͰ // ݱࡏ࣌ؒΛਐΊͨ࣌ؒʹͯ͠ advance(by:)Λऴྃ // ݱࡏ࣌ؒΛਐΊͨ࣌ؒ >= εέδϡʔϧ͞ΕͨΠϕϯτ࣌ؒ now nextDate finalDate advance(by:)

Slide 65

Slide 65 text

// ݱࡏ͔࣌ؒΒࢦఆ࣌ؒΛਐΊͨ࣌ؒ finalDate // ݱࡏ࣌ؒ <= ਐΊͨ࣌ؒͳΒ ͦͷؒϧʔϓʢͭ·Γݱࡏ࣌ؒ͸ਐΊΒΕΔʣ // scheduledऔΓग़ͤͨΒΞΫγϣϯΛ࣮ߦͯ͠࡟আ͓ͯ͘͠ // ݱࡏ࣌ؒΛਐΊͨ࣌ؒ͸ɺ·ͩεέδϡʔϧ͞ΕͨΠϕϯτͷ࣌ؒʹಧ͍ͯͳ͍ͷͰ // ݱࡏ࣌ؒΛਐΊͨ࣌ؒʹͯ͠ advance(by:)Λऴྃ // ݱࡏ࣌ؒΛεέδϡʔϧ͞ΕͨΠϕϯτ࣌ؒ·ͰਐΊΔ // ݱࡏ࣌ؒΛਐΊͨ࣌ؒ >= εέδϡʔϧ͞ΕͨΠϕϯτ࣌ؒ now nextDate finalDate advance(by:)

Slide 66

Slide 66 text

• ͦ΋ͦ΋PublisherΛSubscribe͞ΕΔͱ • SchedulerΛݺͼग़͍ͯ͠ΔॲཧΩϡʔΛม͑ΔΘ͚͚ͩͲ • ΧελϜSchedulerΛ࡞ΔͱɺΠϕϯτͷൃՐ࣌ؒ·Ͱऔಘ͢Δ ͜ͱ ΋ Ͱ͖Δ

Slide 67

Slide 67 text

TestScheduler pointfreeco/combine-schedulers https://github.com/pointfreeco/combine-schedulers/blob/0.1.2/Sources/CombineSchedulers/TestScheduler.swift

Slide 68

Slide 68 text

https://github.com/pointfreeco/swift-composable-architecture/blob/0.8.0/Examples/Search/Search/SearchView.swift debounceΦϖϨʔλ͸࣮ࡍ͸ UpstreamΛsubscribeͯ͠Δɻ ͦͷͱ͖ 0.3ඵޙͱ͍͏৘ใΛ͍࣋ͬͯΔɻ εέδϡʔϥ͸Πϕϯτͷ ΩϡʔʹͦΕΛอ࣋ͯ͠Δ લ൒Ͱࣔͨ͠ςετίʔυΛݟฦͯ͠ΈΑ͏

Slide 69

Slide 69 text

ͭ·Γ…

Slide 70

Slide 70 text

TestScheduler͸Πϕϯτ͕Կඵޙʹ ى͜Δ͔ΛCombineͷ࢓૊Έ্஌Δ ͜ͱ͕Ͱ͖Δ

Slide 71

Slide 71 text

TestScheduler͸advanceϝιουͰ ೚ҙͷ࣌ؒʹਐΊΔ͜ͱ͕Ͱ͖Δ

Slide 72

Slide 72 text

ͳͷͰɺTCA͸Πϕϯτ͕೚ҙͷ࣌ؒ ʹ࣮ߦ͞ΕΔͷΛݟӽͨ͠ςετίʔ υΛॻ͘͜ͱ͕Ͱ͖Δʢඇಉظ࣮ߦΛ Ϝμʹ଴ͨͳ͍͍ͯ͘ʣ

Slide 73

Slide 73 text

·ͱΊ • CombineͷScheduler͸ΩϡʔΛ੾Γସ͑ΒΕΔΑ͏ʹͳ͍ͬͯΔ ͕ɺ͍ͭͰʹΠϕϯτͷ࣮ߦ࣌ؒΛऔಘͰ͖Δ • combine-schedulersͰCombine͸ςετίʔυͷ࣌ؒΛ੍ޚͰ͖Δ • RxSwiftͷςετίʔυ͸࣌ؒΛԾ૝తʹѻ͑Δ • CombineͷSchedulerͰ΋Ծ૝࣌ؒతʹѻ͑Δ͔ʁͱ͍͏ͷ͸΍Ε͹ Ͱ͖ͦ͏Ͱ͸͋Δ͕ɺ΍Δඞཁੑ͸ͳ͍