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
Intro to Rx-Swift
Search
Hamdullah shah
July 18, 2016
Technology
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Intro to Rx-Swift
Introduction to Rx-Swift at MYCocoaHeads July meet-up
Hamdullah shah
July 18, 2016
Other Decks in Technology
See All in Technology
The future of architectural work
ufried
0
150
攻撃 3 時間 vs 復旧 10 時間。アクセスキー流出の非対称性を体感するために CTF を作った話
kazzpapa3
1
140
AI時代に求められる優秀なTechLeadの振る舞い
pospome
4
5.8k
AX時代の自治体支援リソース再配分と役割分担の再構成:戦略とロードマップ(概要)
sishi2026
0
190
Strands Decider 2BでAWSアップデートの目利きをしてみた
sato4mi
1
110
公共システムAdventCalendar2026
toru_kubota
0
160
セキュリティ専任チームなしで攻撃を先回りするSREが実践したSIEM on Amazon OpenSearch Service
cscengineer
PRO
0
140
デザインレビューは自動化できるのか?─ Flutter × Figma で UI 品質保証を考える
techiro
2
790
新卒エンジニア、 介護士になる
ryu1013
1
680
2026 Apache Flink Community Checkpoint
rmetzger
0
160
スマートロックを支えるFlutter × ネイティブ連携の実践 / Flutter and Native Integration in Practice: Powering Smart Locks
bitkey
PRO
0
150
cdkd (CDK Direct)
gotok365
3
200
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
600
Reality Check: Gamification 10 Years Later
codingconduct
0
2.4k
RailsConf 2023
tenderlove
30
1.6k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
400
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Why Our Code Smells
bkeepers
PRO
340
58k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
How to build a perfect <img>
jonoalderson
1
6.2k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
320
Crafting Experiences
bethany
1
420
ラッコキーワード サービス紹介資料
rakko
5
5.7M
Transcript
Rx-Swift Hamdullah shah
[email protected]
What’s RxSwift ? Reactive Extension http://reactivex.io
Reactive Programming Observable Pattern + Iterator Pattern + Functional Programming
best practices
var generator = [1,2,3,4,5].generate() while let elem = generator.next() {
print(elem) } Iterator: NSNotificationCenter.defaultCenter().addObserver( self, selector: #selector(batteryLevelChanged), name: UIDeviceBatteryLevelDidChangeNotification, object: nil) Observer:
Functional Programming [1, 2, 3, 4, 5, 6] .filter {
$0 % 2 == 0 } .map { $0 * 5 } .reduce(0, combine: +)
Instead of Array Values, Can we do this with Events
?
I/O Async Events
Array<T> Observable<T>
public enum Event<Element> { /// Next element is produced. case
Next(Element) /// Sequence terminated with an error. case Error(ErrorType) /// Sequence completed successfully. case Completed } X
Subscribing for Data [1, 2, 3, 4, 5, 6] .toObservable()
.subscribeNext { print($0) } “1” “2” “3” “4” “5” “6”
[1,2,3,4,5,6] .toObservable() .subscribe(onNext: { (intValue) in //pumped out int },
onError: { (error) in //ERROR! }, onCompleted: { //There are no more signals }) { //we disposed this subscription }) Subscribing for Data, Error and Completion
Create from Existing Object [1, 2, 3, 4, 5, 6]
.toObservable() textField.rx_text .asObservable() NSURLSession.sharedSession() .rx_JSON(request) *RxCocoa
Memory Management let disposeBag = DisposeBag() let gestureRecognizer = UIGestureRecognizer()
gestureRecognizer.rx_event .subscribeNext { [weak self]_ in self?.processDetectedTap() } .addDisposableTo(disposeBag) view.addGestureRecognizer(gestureRecognizer)
Creating Observables • asObservable • create • deferred • empty
• error • toObservable (array) • interval • never • just • of • range • repeatElement • timer Filtering Observables • debounce / throttle • distinctUntilChanged • elementAt • filter • sample • skip • take • takeLast • single Transforming Observables • buffer • flatMap • flatMapFirst • flatMapLatest • map • scan • window Combining Observables • merge • startWith • switchLatest • combineLatest • zip Error Handling Operators • catch • retry • retryWhen Observable Utility Operators • delaySubscription • do / doOnNext • observeOn / observeSingleOn • subscribe • subscribeOn • timeout • using • debug Conditional and Boolean Operators • amb • skipWhile • skipUntil • takeUntil • takeWhile Mathematical and Aggregate Operators • concat • reduce / aggregate • toArray Connectable Observable Operators • multicast • publish • refCount • replay • shareReplay Operators http://rxmarbles.com
• Subject • BehaviorSubject • PublishSubject • ReplaySubject More Definitions
• Subject • BehaviorSubject • PublishSubject • ReplaySubject More Definitions
“Variable”
Now Threads
None
Demo
Thanks :) Questions ????
Thanks :) Questions ????