728x90

Rx 5

[RxDataSources] RxTableViewSectionedAnimatedDataSource

안녕하세요. 저번 글에서는 RxDataSources를 간단하게 알아보는 시간을 가졌는데요. 애니메이션 처리가 필요하다면 RxTableViewSectionedAnimatedDataSource를 사용해야 한다고 마지막에 말했었죠?? 이번에는 RxTableViewSectionedAnimatedDataSource를 써보는 시간을 가져볼게요. (전체 코드는 여기를 참고해주세요 ^^) RxDataSources(RxTableViewSectionedReloadDataSource)는 기본적으로 4가지 스텝으로 진행됩니다. 1. Item 구조체 생성 2. SectionModelType 프로토콜을 준수하는 Section 구조체 생성 3. dataSource 객체 생성 4. TableView(또는 CollectionView)..

Rx 2022.11.12

[RxDataSources] RxDataSources 맛보기

안녕하세요. 이번에는 RxDataSources에 대해 알아볼게요. (전체 코드는 여기를 참고해주세요 ^^) # RxDataSources란? 이름에서부터 알 수 있듯이, RxDataSources는 RxSwift 용 UITableView와 UICollectionView의 DataSources 관련 라이브러리입니다. RxSwift와 RxCocoa만을 사용해서 UITableView를 만든다고 했을 때, 아래 코드는 가장 쉽고 빠르게 구현한 방법일 거예요. 다만, 여러 Section이 존재하는 경우 또는 insert, move, delete 할 때 애니메이션이 들어가야 하는 경우는 처리할 수가 없어요. 이때 RxDataSources를 사용하면 쉽게 처리할 수 있다고 합니다ㅎㅎ RxDataSources는 크게 아래..

Rx 2022.11.06

[RxSwift 6.1] withUnretained, subscribe(with:onNext:etc)

안녕하세요. 이번에는 RxSwift 6과 RxSwift 6.1에 새롭게 추가된 withUnretained operator와 subsubscribe(with:onNext:onError:onCompleted:onDisposed:) API에 대해 알아볼게요. # 1. withUnretained Swift 클로저는 내부에서 self에 접근해야 할 때 주의해야 합니다. 바로 retain cycle 때문인데요. (더 자세한 내용은 클로저에서 [weak self] 사용할 때 주의할 점3 글을 참고해주세요.) 그래서 클로저 안에서 self의 약한 참조를 갖기 위해 아래처럼 [weak self]를 사용합니다. (guard-let 구문 하고 세트로도 자주 사용하죠ㅎㅎ) 즉, RxSwift에서는 대부분 클로저를 사용하기 때..

Rx 2022.10.11

[ReactorKit] @Pulse

안녕하세요. 요즘 업무가 많아서.. 글 쓰는 게 좀 뜸했네요...ㅠㅠ 늦었지만, 이번에는 ReactorKit의 @Pulse 라는 property wrapper에 대해 알아볼게요. (이전 [ReactorKit] ReactorKit 입문 글에서 사용했던 Counter 예제를 이어서 사용할 겁니다.) # @Pluse 란? Pulse has diff only when mutated To explain in code, the results are as follows. Use when you want to receive an event only if the new value is assigned, even if it is the same value. like alertMessage. 'Pulse는 수정될 때(mut..

Rx 2022.09.30

[ReactorKit] ReactorKit 입문

안녕하세요. ReactorKit에 대해 처음 접하고 공부한 것들을 정리해보려고 해요. # 0. ReactorKit을 알게 된 배경 MVVM과 Rx를 어떻게 하면 구조적으로 아름답게 구현할까 고민하던 중, Input-Output 구조라는 게 있다는 것을 알게 되었어요. [참고 목록] https://linux-studying.tistory.com/28 https://mildwhale.github.io/2020-04-16-mvvm-with-input-output/ https://coding-idiot.tistory.com/7 https://ios-development.tistory.com/173 Input-Output 구조라는 용어가 공식적으로 개발자들 사이에서 널리 사용되는 것은 아닌 것 같지만.. 간략하게..

Rx 2022.09.11