Rx playground
这个playground写的太好了,有playground格式的注释,类似markdown语法,可参考.
content
- Introduction
- Creating and Subscribing to Observables
- Working with Subjects
- Combining Operators
- Transforming Operators
- Filtering and Conditional Operators
- Mathematical and Aggregate Operators
- Connectable Operators
- Error Handling Operators
- Debugging Operators
随便记
- repeat take, 最后是会有completed的
example("repeatElement") {
let disposeBag = DisposeBag()
Observable.repeatElement("🔴")
.take(3)
.subscribe(onNext: { print($0) })
// .subscribe { print($0) }
.disposed(by: disposeBag)
}
- sucribe是顺序执行的,之前官方文档的getting start中的交错并行,是因为哪个obersvable是有计时器的。
let thesequence = Observable<String>.create { observer in
print("Emitting...")
observer.onNext("🐶")
observer.onNext("🐱")
observer.onNext("🐵")
return Disposables.create()
}
thesequence
.subscribe(onNext: { print($0) })
.disposed(by: disposeBag)
thesequence
.subscribe(onNext: { print($0) })
.disposed(by: disposeBag)
print:
Emitting...
🐶
🐱
🐵
Emitting...
🐶
🐱
🐵
-
顺便学了一下Swift.Error的用法,看Xcode自带的文档。所以,就应该搞清楚每一个遇到的问题,就能成为大神。
-
Subjects
比较特殊哦,看demo
-
Combination Operators
-
ransforming Operators
-
Filtering and Conditional Operators
-
Mathematical and Aggregate Operators
-
Connectable Operators
-
Error Handling Operators
-
Debugging Operators