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.5k
ReactiveCocoaでのフロー制御の例
ReactiveCocoa 2.xを使ったサンプルアプリでのフロー制御例を紹介します。
matuyuji
July 26, 2014
Tweet
Share
More Decks by matuyuji
See All by matuyuji
Emacs × Touch Bar
matuyuji
2
1.8k
ARKit + SceneKitでMinesweeperを作ってみた
matuyuji
1
790
Go + QtでiOS アプリ開発
matuyuji
0
400
@_specialized なお話し
matuyuji
0
490
Xcode Souce Code Extensionを使ってみた
matuyuji
0
390
Codebeatを 試してみた
matuyuji
0
780
React Nativeで UIコンポーネントをつくる
matuyuji
0
1k
React Nativeを使ってみた
matuyuji
0
1.3k
SwiftでLens
matuyuji
1
980
Other Decks in Programming
See All in Programming
CSC305 Summer Lecture 12
javiergs
PRO
0
130
Scale out your Claude Code ~自社専用Agentで10xする開発プロセス~
yukukotani
9
2.6k
『リコリス・リコイル』に学ぶ!! 〜キャリア戦略における計画的偶発性理論と変わる勇気の重要性〜
wanko_it
1
600
The state patternの実践 個人開発で培ったpractice集
miyanokomiya
0
150
コンテキストエンジニアリング Cursor編
kinopeee
1
710
AI OCR API on Lambdaを Datadogで可視化してみた
nealle
0
180
SOCI Index Manifest v2が出たので調べてみた / Introduction to SOCI Index Manifest v2
tkikuc
1
110
AIでLINEスタンプを作ってみた
eycjur
1
200
TROCCO×dbtで実現する人にもAIにもやさしいデータ基盤
nealle
0
330
State of CSS 2025
benjaminkott
1
120
自作OSでDOOMを動かしてみた
zakki0925224
1
1.4k
decksh - a little language for decks
ajstarks
4
21k
Featured
See All Featured
Speed Design
sergeychernyshev
32
1.1k
Automating Front-end Workflow
addyosmani
1370
200k
KATA
mclloyd
32
14k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
BBQ
matthewcrist
89
9.8k
Testing 201, or: Great Expectations
jmmastey
45
7.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
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