WWDC19
=================
- Table of Contents
- Combine in Practice - Thursday * @Published * currentValuePublisher() * passThroughPublisher() * eraseToAnyPublisher * debounce * removeDuplicates * sink() & assign()
Session materials: https://developer.apple.com/videos/play/wwdc2019/721/
This is an example oriented heavy code focused session. Please follow the session materials.
- Combine has a built in bakc-pressure compared to RxSwift!
- It doesn't have disposeBags and the allocation is handled automatically
- There is also a built-in cancel mechanism to terminate an ongoing emmission
- A new property wrapper to turn properties into publishers at the same time
- Similar to
Variable<T>
orBehaviorRelay<T>
on RxSwift
- Similar to
@Published var foo: String
self.foo = 1
let boo = self.foo // Immediately assigns the current value as 1
foo.sink() {
// subscription stream will get 1 and 2
}
self.foo = "2"
- Holds the last emitted value as
BehaviorSubject
or similar toReplaySubject
in RxSwift
- Acts like a bridge from non rx world to rx world. (Similar to
publishSubject
in RxSwift)
- casts a given chain into a publisher to be used again across the API
- debounces the emission and can schedule on a given thread
-
distinctUntilChanged() on Rx
-
There are more than 90 common Rx operators built into Combine!
subscribe()
&bind()
on RxSwift to get the emitted value on a subscriber