a RxSwift Related component, help checking property has been filled
another congeneric project: https://github.com/xattacker/RequiredPropertyChecker (which implemented by Combine)
RxRequiredPropertyChecker can be added to your project using CocoaPods 0.36 or later by adding the following line to your Podfile:
pod 'RxSwift'
pod 'RxCocoa'
pod 'RxRequiredPropertyChecker'
To add RxRequiredPropertyChecker to a Swift Package Manager based project, add:
.package(url: "https://github.com/xattacker/RxRequiredPropertyChecker.git", .upToNextMajor(from: "1.1.1")),
.package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "6.0.0")),
to your Package.swift
files dependencies
array.
import RxRequiredPropertyChecker
// make the component implement protocol RequiredProperty
extension UITextField: RequiredProperty
{
public var isFilled: Bool
{
return (self.text?.count ?? 0) > 0
}
public var isFilledBinding: Driver<Bool>
{
return self.rx.text.map { $0?.count ?? 0 > 0 }.asDriver(onErrorJustReturn: false)
}
}
// then add the RequiredProperty instance into RxRequiredPropertyChecker
let textField: UITextField
let checker = RxRequiredPropertyChecker()
checker.add(textField)
// bind checker with other
checker.rx.isFilled.drive(self.button.rx.isEnable)
.disposed(by: self.disposeBag)
link |
Stars: 0 |
Last commit: 2 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics