RxTodo is an iOS application developed using The Reactive Architecture. This project is for whom having trouble with learning how to build a RxSwift application due to lack of references. (as I did 😛)
- The Reactive Architecture
- Using RxDataSources
- Observing model create/update/delete across the view controllers
- Navigating between view controllers
- Immutable models
- Testing with RxExpect
-
View doesn't have control flow. View cannot modify the data. View only knows how to map the data.
Bad
viewReactor.titleLabelText .map { $0 + "!" } // Bad: View should not modify the data .bindTo(self.titleLabel)
Good
viewReactor.titleLabelText .bindTo(self.titleLabel.rx.text)
-
View doesn't know what ViewReactor does. View can only communicate to ViewReactor about what View did.
Bad
viewReactor.login() // Bad: View should not know what ViewReactor does (login)
Good
self.loginButton.rx.tap .bindTo(viewReactor.loginButtonDidTap) // "Hey I clicked the login button" self.usernameInput.rx.controlEvent(.editingDidEndOnExit) .bindTo(viewReactor.usernameInputDidReturn) // "Hey I tapped the return on username input"
-
Model is hidden by ViewReactor. ViewReactor only exposes the minimum data so that View can render.
Bad
struct ProductViewReactor { let product: Driver<Product> // Bad: ViewReactor should hide Model }
Good
struct ProductViewReactor { let productName: Driver<String> let formattedPrice: Driver<String> let formattedOriginalPrice: Driver<String> let isOriginalPriceHidden: Driver<Bool> }
- iOS 8+
- Swift 3
- CocoaPods
Discussion and pull requests are welcomed 💖
RxTodo is under MIT license. See the LICENSE for more info.