이전 챕터에서 실습한 Combinestagram을 이어갑니다. 최근에 '아 이래서 내가 Rx를 못 따라가고 있는 모양이구나' 생각하게 만든 문장이 튀어나왔습니다.
Observables are lazy, pull-driven sequence. Simply calling a bunch of operators on an Observable doesn't involve any actual work. The moment you call subscribe(...) directly on an observable or on one of the operators applied to it, that's when the Observable livens up and starts producing elements.
Hot Observable을 Notification으로 생각하면서 그동안 작업을 해왔었는데... Observable.create 내부에 로직을 어디까지 포함시켜야하는지 아직 좀 혼란스럽습니다. 여튼, Observable을 Notification처럼 다루려고 한다면 share()가 필수입니다.
public func share(replay: Int = 0, scope: SubjectLifetimeScope = .whileConnected)
-> Observable<Element>
RxSwift. Ch 8. Transforming Operators in Practice (0) | 2020.05.01 |
---|---|
RxSwift. Ch 7. Transforming Operators (0) | 2020.04.26 |
RxSwift. Ch 5. Filtering Operators (0) | 2020.04.20 |
RxSwift. Ch 4. Observables & Subjects in Practice (0) | 2020.04.19 |
RxSwift. Ch 3. Subjects (0) | 2020.04.18 |
댓글 영역