Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RxFeedback使ってみた
Search
yukatou
January 23, 2018
Technology
2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RxFeedback使ってみた
yukatou
January 23, 2018
Other Decks in Technology
See All in Technology
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
190
Classmethod Company Deck
satoshi7
1
680
DevelopersIO 2026 知識の地図を描く ─ オントロジーとは何か?
ishikawa_satoru
1
1.7k
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
260
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
940
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
120
Claude Code本は、どのように執筆チームで書かれたか
oikon48
1
380
コンテナ運用におけるネットワーク・コンテナコストの削減方法/How to Reduce Network and Container Costs in Container Operations
masakiokuda
1
150
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
1
190
Getting Started with Google Antigravity
glaforge
0
300
AI × アーキテクト 第1・2章|生成AIの課題とアーキテクトの素養
daidaidai
0
170
go-sqletch
moznion
0
140
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
Claude Code のすすめ
schroneko
67
230k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
It's Worth the Effort
3n
188
29k
Mobile First: as difficult as doing things right
swwweet
225
10k
Code Reviewing Like a Champion
maltzj
529
40k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Odyssey Design
rkendrick25
PRO
2
870
The Invisible Side of Design
smashingmag
301
52k
BBQ
matthewcrist
90
10k
Paper Plane
katiecoart
PRO
5
54k
WCS-LA-2024
lcolladotor
0
890
Transcript
RxFeedbackͬͯΈͨ Nagoya iOS Meetup Vol.1 2018.1 @katoyan_
ࣗݾհ • @katoyan_ • ͓ͱͱ໊͠ݹʹUλʔϯ͖ͯ͠·ͨ͠ • ࣄ iOS, αʔόαΠυ •
࠷ۙԾ௨՟ʹϋϚͬͯ·͢
RxSwiftͬͯ·͔͢ʁ
None
RxSwiftͰ։ൃ͢Δͱ͖ ΞʔΩςΫνϟͬͯԿ͕ྑ͍ΜͩΖ͏ʁ MVVM? Flux/Redux? Clean Architecture?
None
IUUQTHJUIVCDPNCFFUIWFO3Y4XJGU$IJOFTF%PDVNFOUBUJPO
RxFeedback • Try! Swift NYC (2017.11) Modern RxSwift Architectures by
Krunoslav Zaher • https://github.com/NoTests/RxFeedback.swift • ݕࡧͯ͠υΩϡϝϯτগɻɻ
RxFeedbackͷߏ The simplest architecture for RxSwift IUUQTHJUIVCDPN/P5FTUT3Y'FFECBDLTXJGU
͋ΕʁReduxʹࣅͯΔؾ͕͢Δ
IUUQTBDBEFNZSFBMNJPQPTUTUSZTXJGUOZDLSVOPTMBW[BIFSNPEFSOSYTXJGUBSDIJUFDUVSFT 3FEVY"QQMJDBUJPO-FWFMͰͭͷେ͖ͳ4UBUF͕ඞཁɻ 3Y'FFECBDL7JFX$POUSPMMFS୯ҐͰ4UBUFΛ࣋ͭ͜ͱՄೳɻ ൖίετ͕Լ͕Δ
typealias Feedback<State, Event> = (Observable<State>) -> Observable<Event> public static func
system<State, Event>( initialState: State, reduce: @escaping (State, Event) -> State, feedback: Feedback<State, Event>... ) -> Observable<State> w JOJUJBM4UBUFॳظ4UBUFΛࢦఆ w SFEVDF&WFOUΛड͚औͬͯɺ4UBUFΛมߋ͢ΔॲཧΛఆٛ w GFFECBDL4UBUFͷมߋΛͱʹ6*Λมߋͨ͠Γɺ&WFOUΛൃՐͤ͞Δॲ ཧΛఆٛ Observable.systemPSDriver.systemͰݺͼग़͠ Interface
None
RxFeedbackͰΞϓϦΛ࡞ͬͯΈͨ Ծ௨՟"1*ΛϦΫΤετͯ݁͠ՌΛ 6*5BCMF7JFXͰදࣔ SFGSFTI$POUSPMMͰ݁ՌΛϦϑϨογϡ 6*5BCMF7JFXͷҰ൪Լ·ͰεΫϩʔϧͨ͠ Βଓ͖ͷσʔλΛऔಘ
State struct State { // ಡΈࠐΈϖʔδ var loadPage: Int? =
1 // ಡΈࠐΈத͔ var loading: Bool = false // ΞΠςϜϦετ var items: [Coin] = [] }
Event enum Event { // ϦϑϨογϡ case refresh // ࣍ͷϖʔδΛϦΫΤετ
case loadNextPage // Ϩεϙϯε case response([Coin]) }
Reducer reduce: { (state: State, event: Event) -> State in
switch event { case .refresh: var results = state results.loadPage = 1 results.loading = true results.items = [] return results case .loadNextPage: var results = state results.loadPage = (results.items.count / fetchCount) + 1 results.loading = true return results case .response(let items): var results = state results.loadPage = nil results.loading = false results.items += items return results } }
Feedback feedback: bind(self) { me, state in let subscriptions: [Disposable]
= [ // itemsΛUITableViewʹBind state.map { $0.items } .drive(me.tableView.rx.items(cellIdentifier: "Cell"))(me.configureCell), // loading ͕falseͰ͋ΕrefreshControlΛఀࢭ state.map { $0.loading }.filter { !$0 } .drive(onNext: { _ in me.refreshControl.endRefreshing() }) ] let events: [Signal<Event>] = [ // RefreshControl͕มߋ͞ΕΕrefreshΠϕϯτΛൃՐͤ͞Δ me.refreshControl.rx.controlEvent(.valueChanged).asSignal().map { _ in Event.refresh }, // UITableViewΛఈ·ͰεΫϩʔϧͨ͠߹loadNextPageΠϕϯτΛൃՐͤ͞Δ state.flatMapLatest { state in if state.loading { return Signal.empty() } return me.tableView.rx.reachedBottom.map { _ in Event.loadNextPage } } ] return Bindings(subscriptions: subscriptions, events: events) }, react(query: { $0.loadPage }, effects: { page in // loadPage͕มߋ͞ΕΔʹݺΕΔ(nilͷ߹ݺΕͳ͍) return api.fetch(page: page, limit: fetchCount) .asSignal(onErrorJustReturn: []) .map(Event.response) })
DEMO
ͬͯΈͨॴײ • State ͱ Event ͷઃܭ͕େࣄ • ׂ͕໌֬ʹͳͬͯΔ͜ͱͰɺՄಡੑྑ͘ͳͬͨ • RxFeedback
Λ͏લͱൺΔͱهड़ྔݮͬͨ • υΩϡϝϯτʢαϯϓϧʣ͕গͳ͍ͷͰਏ͔ͬͨ
͓ΘΓ https://github.com/yukatou/CryptoChecker-RxFeedback