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
770
Go + QtでiOS アプリ開発
matuyuji
0
380
@_specialized なお話し
matuyuji
0
470
Xcode Souce Code Extensionを使ってみた
matuyuji
0
340
Codebeatを 試してみた
matuyuji
0
730
React Nativeで UIコンポーネントをつくる
matuyuji
0
990
React Nativeを使ってみた
matuyuji
0
1.3k
SwiftでLens
matuyuji
1
940
Other Decks in Programming
See All in Programming
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
220
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
290
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
300
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
500
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
810
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1.1k
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
140
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
php-conference-japan-2024
tasuku43
0
350
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
800
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Practical Orchestrator
shlominoach
186
10k
How STYLIGHT went responsive
nonsquared
96
5.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Done Done
chrislema
182
16k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
The World Runs on Bad Software
bkeepers
PRO
66
11k
The Cost Of JavaScript in 2023
addyosmani
46
7k
Statistics for Hackers
jakevdp
796
220k
Bash Introduction
62gerente
609
210k
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