魏名华

不要偷懒,做更好的自己

Nothing


No Welcome Message

Rx_playground

Rx playground

这个playground写的太好了,有playground格式的注释,类似markdown语法,可参考.

content

  1. Introduction
  2. Creating and Subscribing to Observables
  3. Working with Subjects
  4. Combining Operators
  5. Transforming Operators
  6. Filtering and Conditional Operators
  7. Mathematical and Aggregate Operators
  8. Connectable Operators
  9. Error Handling Operators
  10. Debugging Operators

随便记

  1. repeat take, 最后是会有completed的
example("repeatElement") {
    let disposeBag = DisposeBag()
    
    Observable.repeatElement("🔴")
        .take(3)
        .subscribe(onNext: { print($0) })
//        .subscribe { print($0) }
        .disposed(by: disposeBag)
}
  1. 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...
🐶
🐱
🐵
  1. 顺便学了一下Swift.Error的用法,看Xcode自带的文档。所以,就应该搞清楚每一个遇到的问题,就能成为大神。

  2. Subjects

比较特殊哦,看demo

  1. Combination Operators

  2. ransforming Operators

  3. Filtering and Conditional Operators

  4. Mathematical and Aggregate Operators

  5. Connectable Operators

  6. Error Handling Operators

  7. Debugging Operators