Taehyeon-Kim / SeSAC

☀️ SeSAC Daily Reporting
27 stars 0 forks source link

[221025] TIL #141

Open Taehyeon-Kim opened 1 year ago

Taehyeon-Kim commented 1 year ago

Stream

Sequence, Iterator Protocol

Observable

Taehyeon-Kim commented 1 year ago

DisposeBag

자자!

Taehyeon-Kim commented 1 year ago

순환 참조 문제 해결

// 기존 해결 방법
signUpButton.rx.tap
    .subscribe { [weak self] _ in
        let alert = UIAlertController(title: "Good", message: nil, preferredStyle: .alert)
        let ok = UIAlertAction(title: "Ok", style: .cancel)
        alert.addAction(ok)
        self?.present(alert, animated: true)
    }
.disposed(by: disposeBag)
// RxSwift 6부터의 해결 방법
signUpButton.rx.tap
    .withUnretained(self)
    .subscribe { vc, _ in
        let alert = UIAlertController(title: "Good", message: nil, preferredStyle: .alert)
        let ok = UIAlertAction(title: "Ok", style: .cancel)
        alert.addAction(ok)
        vc.present(alert, animated: true)
    }
.disposed(by: disposeBag)
Taehyeon-Kim commented 1 year ago

Observable의 한계

Subject의 등장 배경

Taehyeon-Kim commented 1 year ago

Subject

옵저버블, 옵저버의 역할을 모두 하는 녀석