Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ReactiveCocoaでのフロー制御の例
Search
matuyuji
July 26, 2014
Programming
0
3.4k
ReactiveCocoaでのフロー制御の例
ReactiveCocoa 2.xを使ったサンプルアプリでのフロー制御例を紹介します。
matuyuji
July 26, 2014
Tweet
Share
More Decks by matuyuji
See All by matuyuji
Emacs × Touch Bar
matuyuji
2
1.7k
ARKit + SceneKitでMinesweeperを作ってみた
matuyuji
1
760
Go + QtでiOS アプリ開発
matuyuji
0
370
@_specialized なお話し
matuyuji
0
460
Xcode Souce Code Extensionを使ってみた
matuyuji
0
330
Codebeatを 試してみた
matuyuji
0
720
React Nativeで UIコンポーネントをつくる
matuyuji
0
980
React Nativeを使ってみた
matuyuji
0
1.2k
SwiftでLens
matuyuji
1
930
Other Decks in Programming
See All in Programming
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
910
最新TCAキャッチアップ
0si43
0
140
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
役立つログに取り組もう
irof
28
9.6k
ヤプリ新卒SREの オンボーディング
masaki12
0
130
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
Macとオーディオ再生 2024/11/02
yusukeito
0
370
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
1
110
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
Featured
See All Featured
Building Applications with DynamoDB
mza
90
6.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Git: the NoSQL Database
bkeepers
PRO
427
64k
How GitHub (no longer) Works
holman
310
140k
Done Done
chrislema
181
16k
Writing Fast Ruby
sferik
627
61k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Agile that works and the tools we love
rasmusluckow
327
21k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Transcript
3FBDUJWF$PDPB Ͱͷϑϩʔ੍ޚͷྫ @matuyuji ! ReactiveCocoaษڧձؔ 2014.7.24
!NBUVZVKJ w TBGYEFWCMPHTQPUKQ w &NBDT͍
3FBDUJWF$PDPBͬͯ ΞϓϦͭͬͯ͘Έͨ w .JP%BTICPBSE w HJUIVCDPNTBGY.JP%BTICPBSE
**+.JPΈ͓ΆΜ"1* w ߴ௨৴༻Ϋʔϙϯͷ0/0'' w Ϋʔϙϯྔɺʑͷར༻ྔ w 3&45"1* w 0"VUI +40/
Δ͜ͱ w +40/औಘ w IUUQTBQJJJKNJPKQNPCJMFEWDPVQPO w IUUQTBQJJJKNJPKQNPCJMFEWMPHQBDLFU w +40/σʔλͷϚʔδ w
0"VUIʹΑΔೝূ τʔΫϯ࠶औಘ
͍ͬͯΔ͜ͱ w +40/औಘ " IUUQTBQJJJKNJPKQNPCJMFEWDPVQPO # IUUQTBQJJJKNJPKQNPCJMFEWMPHQBDLFU w
+40/σʔλͷϚʔδ w 0"VUIʹΑΔೝূ τʔΫϯ࠶औಘ → AFNetworking-RACExtensionsͷ rac_startJSONRequestOperationWithRequest: → concat:ͰͱΓ͚͋͑ͣͬͭ͘Δɻ map:ͰMantle͔ͬͯΒϚʔδ → ΞΫηετʔΫϯΛnilʹͯ͠࠶࣮ߦ
+40/σʔλͷऔಘ (A) (B) rac_startJSONRequest…: defer defer rac_startJSONRequest…: concat: collect NSDict
NSDict NSDict × 2 NSArray → AFNetworking-RACExtensionsͷ rac_startJSONRequestOperationWithRequest:
γάφϧͰͷΠϕϯτ next completed error id NSError
"DPODBU# next completed error NSError id next id completed error
NSError
+40/σʔλͷऔಘ (A) (B) rac_startJSONRequest…: defer defer rac_startJSONRequest…: concat: collect NSDict
NSDict NSDict × 2 NSArray
+40/σʔλͷऔಘ - (RACSignal*)loadInformationSignal { RACSignal* coupon = [RACSignal defer:^RACSignal* {
return [self.restHelper getCoupon]; }]; ! RACSignal* packet = [RACSignal defer:^RACSignal* { return [self.restHelper getPacket]; }]; ! RACSignal* sig = [[coupon concat:packet] collect]; return sig; } தͰrac_startJSONRequestOperationWithRequest:ΛݺͿ
0"VUIͷೝূ - (RACSignal*)loadInformationSignal { RACSignal* coupon = [RACSignal defer:^RACSignal* {
return [self.restHelper getCoupon]; }]; ! RACSignal* packet = [RACSignal defer:^RACSignal* { return [self.restHelper getPacket]; }]; ! RACSignal* sig = [[coupon concat:packet] collect]; return self.restHelper.accessToken ? sig : [[[self.restHelper authorize] catch:self.errorBlock] concat:sig]; } complete͔error͚ͩฦ͢γάφϧ
0"VUIͷೝূ (A) (B) rac_start…: defer defer concat: collect NSDict NSDict
NSDict × 2 NSArray rac_start…: concat: authorize catch: NSArray
MPBE*OGPSNBUJPO4JHOBM (A) (B) rac_start…: defer defer concat: collect NSDict NSDict
NSDict × 2 NSArray rac_start…: concat: authorize catch: NSArray
MPBE*OGPSNBUJPO4JHOBM - (RACSignal*)loadInformationSignal { RACSignal* coupon = [RACSignal defer:^RACSignal* {
return [self.restHelper getCoupon]; }]; ! RACSignal* packet = [RACSignal defer:^RACSignal* { return [self.restHelper getPacket]; }]; ! RACSignal* sig = [[coupon concat:packet] collect]; return self.restHelper.accessToken ? sig : [[[self.restHelper authorize] catch:self.errorBlock] concat:sig]; }
ϚʔδͱτʔΫϯ࠶औಘ [[[self loadInformationSignal] catch: ^RACSignal *(NSError *error) { if (/*ΞΫηετʔΫϯ͕ແޮ*/)
{ self.restHelper.accessToken = nil; return [self loadInformationSignal]; } return [RACSignal empty]; //ଞͷΤϥʔ͖͋ΒΊΔ }] map:^(NSArray* array) { // MantleͰΦϒδΣΫτ࡞͔ͯ͠ΒɺσʔλΛ·ͱΊΔ }];
τʔΫϯ࠶औಘ (A) (B) rac_start…: defer defer concat: collect NSDict NSDict
NSDict × 2 NSArray rac_start…: concat: authorize catch: NSArray
ͬͨ͜ͱ w +40/औಘ " IUUQTBQJJJKNJPKQNPCJMFEWDPVQPO # IUUQTBQJJJKNJPKQNPCJMFEWMPHQBDLFU w
+40/σʔλͷϚʔδ w 0"VUIʹΑΔೝূ τʔΫϯ࠶औಘ → AFNetworking-RACExtensionsͷ rac_startJSONRequestOperationWithRequest: → concat:ͰͱΓ͚͋͑ͣͬͭ͘Δɻ map:ͰMantle͔ͬͯΒϚʔδ → ΞΫηετʔΫϯΛnilʹͯ͠࠶࣮ߦ
ͬͨϥΠϒϥϦ w 3FBDUJWF$PDPB w "'/FUXPSLJOH3"$&YUFOTJPOT w 6OEFSTDPSFN w .BOUMF w
58.FTTBHF#BS.BOBHFS w 75"DLOPXMFEHFNFOUT7JFX$POUSPMMFS w 9:1JF$IBSU w J041MPU
ؔ࿈ใ w 3FBDUJWF$PDPBؔ࿈ϦϯΫͷ·ͱΊ w TBGYEFWCMPHTQPUKQSFBDUJWFDPDPBIUNM