All Projects → Pircate → RxSwiftDemo

Pircate / RxSwiftDemo

Licence: other
RxSwift Demo

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to RxSwiftDemo

Papr
🌁 An Unsplash app for iOS
Stars: ✭ 1,025 (+5294.74%)
Mutual labels:  rxswift, mvvm
Rxmarvel
Playing around marvel public API with RxSwift, Argo, Alamofire
Stars: ✭ 86 (+352.63%)
Mutual labels:  rxswift, mvvm
Mvvmc Splitviewcontroller
Example project with UITabBarController inside UISplitViewController using RxSwift and MVVM-C architecture.
Stars: ✭ 45 (+136.84%)
Mutual labels:  rxswift, mvvm
Coordinator Mvvm Rx Example
Example of MVVM-C architecture implemented with RxSwift
Stars: ✭ 469 (+2368.42%)
Mutual labels:  rxswift, mvvm
Xcoordinator
🎌 Powerful navigation library for iOS based on the coordinator pattern
Stars: ✭ 1,752 (+9121.05%)
Mutual labels:  rxswift, mvvm
Iossampleapp
Sample iOS app demonstrating Coordinators, Dependency Injection, MVVM, Binding
Stars: ✭ 510 (+2584.21%)
Mutual labels:  rxswift, mvvm
Jetchat
 Swift5.0编写的简仿微信聊天应用,完美支持表情键盘、单聊、群聊、本地消息会话缓存。
Stars: ✭ 61 (+221.05%)
Mutual labels:  rxswift, mvvm
Verge
🟣 Verge is a very tunable state-management engine on iOS App (UIKit / SwiftUI) and built-in ORM.
Stars: ✭ 273 (+1336.84%)
Mutual labels:  rxswift, mvvm
Bark
Bark is an iOS App which allows you to push customed notifications to your iPhone
Stars: ✭ 2,371 (+12378.95%)
Mutual labels:  rxswift, mvvm
Rxgithub
An example of MVVM using RxSwift and Swinject (DI)
Stars: ✭ 109 (+473.68%)
Mutual labels:  rxswift, mvvm
Rxviewmodel
ReactiveViewModel-esque using RxSwift
Stars: ✭ 392 (+1963.16%)
Mutual labels:  rxswift, mvvm
Swifthub
GitHub iOS client in RxSwift and MVVM-C clean architecture
Stars: ✭ 2,330 (+12163.16%)
Mutual labels:  rxswift, mvvm
Rxxmly
RxSwift 实现MVVM高仿喜马拉雅的函数响应式编程
Stars: ✭ 313 (+1547.37%)
Mutual labels:  rxswift, mvvm
Ios Architecture
A collection of iOS architectures - MVC, MVVM, MVVM+RxSwift, VIPER, RIBs and many others
Stars: ✭ 901 (+4642.11%)
Mutual labels:  rxswift, mvvm
Cleanarchitecturerxswift
Example of Clean Architecture of iOS app using RxSwift
Stars: ✭ 3,256 (+17036.84%)
Mutual labels:  rxswift, mvvm
Ios
A sample project demonstrating MVVM, RxSwift, Coordinator Pattern, Dependency Injection
Stars: ✭ 49 (+157.89%)
Mutual labels:  rxswift, mvvm
mvcvm-swift-file-templates
Swift file templates for boosting mobile app development.
Stars: ✭ 16 (-15.79%)
Mutual labels:  rxswift, mvvm
MovieInfoMVVMiOS
Movie Info app using TMDb API built with MVVM
Stars: ✭ 38 (+100%)
Mutual labels:  rxswift, mvvm
Qiitawithfluxsample
A sample project uses Flux and MVVM features with RxSwift.
Stars: ✭ 94 (+394.74%)
Mutual labels:  rxswift, mvvm
Unio
🔄 KeyPath based Unidirectional Input / Output framework with RxSwift.
Stars: ✭ 139 (+631.58%)
Mutual labels:  rxswift, mvvm

LightCloud

RxSwift 登录/注册/搜索/编辑/网络 Demo

ViewModel

final class LoginViewModel {
    
    struct Input {
        let username: Observable<String>
        let password: Observable<String>
        let captchaTap: ControlEvent<Void>
        let loginTap: ControlEvent<Void>
    }
    
    struct Output {
        let isEnabled: Driver<Bool>
        let captcha: Driver<(title: String, isEnabled: Bool)>
        let login: Driver<Bool>
        let state: Driver<UIState>
    }
}

extension LoginViewModel: ViewModelType {
    
    func transform(_ input: LoginViewModel.Input) -> LoginViewModel.Output {
        let isEnabled = input.verifyloginButton()
        
        let state = State()
        let captcha = input.requestLoginCaptcha(state)
        let login = input.requestLogin(state)
        
        return Output(isEnabled: isEnabled,
                      captcha: captcha,
                      login: login,
                      state: state.asDriver(onErrorJustReturn: .idle))
    }
}

fileprivate extension LoginViewModel.Input {
    
    func verifyloginButton() -> Driver<Bool> {
        return Observable
        	.combineLatest(username.isEmpty, password.isEmpty) { !$0 && !$1 }
            .asDriver(onErrorJustReturn: false)
    }
    
    func requestLoginCaptcha(_ state: State) -> Driver<(title: String, isEnabled: Bool)> {
        return captchaTap.withLatestFrom(username)
            .flatMap{
                LCUser.rx.requestLoginCaptcha(mobile: $0)
                    .trackState(state, success: "验证码已发送")
                    .catchErrorJustComplete()
            }
            .flatMap(to: 60.countdown())
            .asDriver(onErrorJustReturn: (title: "重新发送", isEnabled: true))
    }
    
    func requestLogin(_ state: State) -> Driver<Bool> {
        let usernameAndPassword = Observable
        .combineLatest(username, password) { (username: $0, password: $1) }
        return loginTap.withLatestFrom(usernameAndPassword)
            .flatMap {
                LCUser.rx.login(mobile: $0.username, captcha: $0.password)
                    .trackState(state, success: "登录成功")
                    .catchErrorJustComplete()
            }
            .map(to: true)
            .asDriver(onErrorJustReturn: false)
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].