RxSwift is a Swift port of Microsoft Reactive Extensions. Like the original Rx, its intention is to enable easy composition of asynchronous operations and event/data streams.
2. Problem
! Kognitivna kompleksnost sustava
! Stanje (kompleksnost, cachevi)
! Višedretvenost (Multithreading)
! Upravljanje resursima
! Oporavak od grešaka
2
3. Kako rješiti ovaj problem
! https://www.youtube.com/watch?v=MseMobwg_mo
Bruce Lee: Right. Right. You see, actually, I do not teach, you know, Karate, because I
do not believe in styles anymore. I mean I do not believe that there is such thing as,
like, a Chinese way of fighting or a Japanese way of fighting...or whatever way of
fighting, because unless a human being has three arms and four legs, there can be no
different form of fighting. But, basically, we only have two hands and two feet. So
styles tend to, not only separate man because they have their own doctrines and the
doctrine became the gospel truth that you cannot change! But, if you do not have
styles, if you just say, "here I am as a human being, how can I express myself totally
and completely?" ...now that way, you won't create a style because style is a
crystallization. That way is a process of continuing growth.
! Problem je univerzalan, zato i rješenje treba biti dovoljno
općenito za sve platforme i okruženje
3
8. RxSwift
let a = Variable(1)
let b = Variable(2)
let c: /* Observable<String> */ = combineLatest(a, b) { $0 + $1 }
>- filter { $0 >= 0 }
>- map { "($0) is positive" }
c >- subscribeNext { println($0) } // prints: 3 is positive
…
a.next(4) // prints: 6 is positive
b.next(-8) // doesn't print anything
a.next(9) // prints: 1 is positive
8
9. RxSwift
! RxSwift je verzija Rx-a za Swift
! Istrazivanje + razvoj je trajao 7 mjesec weekenda :)
! Objavljen na GH sredinom 4. mjeseca (2015)
! ispiriran je originalnom verzijom Rx.NET koja je evoluirala
proteklih 6 godina
! RxSwift je poprilično stabilan i spreman za produkcijsku
upotrebu
! ~30k linija swift koda, 430 unit testova
9
10. Kako početi koristiti
! postoje neke očite primjene
! throttling, autocomplete, image loader,
NSFetchedResultsController, NSNotificationCenter,
delegati
! nije sve ili ništa
! moguće je napisati samo dijelove aplikacije reaktivno, a
ostatak imperativno
! tko će naučiti sve te operatore
! što ako nema nekog operatora
10
11. Zamke
! za naprednije primjene bilo bi dobro imati dublje
shvaćanje kako Rx radi
! obično imperativni način razmišljanja je velika prepreka
! savjet, prvo naučite Haskell :)))
! nije silver bullet
11