RxCocoa 의 Traits 중 하나
share(replay: 1, scope: .whileConnected)
와 같이 동작합니다.
asDriver()
public func asDriver(onErrorJustReturn: Element) -> Driver<Element> {
let source = self
.asObservable()
.observeOn(DriverSharingStrategy.scheduler)
.catchErrorJustReturn(onErrorJustReturn)
return Driver(source)
}
var disposeBag = DisposeBag()
var sequence = Observable<Int>.interval(.seconds(1), scheduler: MainScheduler.instance)
.take(5)
.asDriver(onErrorJustReturn: 0)
sequence.drive(onNext: {
print($0)
}).disposed(by: disposeBag)