This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let vSubject = Variable<Int>(0) | |
let vSubscribe1 = vSubject.asObservable() | |
.subscribe(onNext: { (value) in | |
print("vSubscribe1 onNext [\(value)]") | |
}) | |
vSubject.value = 1 | |
let vSubscribe2 = vSubject.asObservable() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let bSubject = BehaviorSubject(value: 0) | |
let subscribe1 = bSubject.subscribe(onNext: { (value) in | |
print("bSubscribe1 onNext [\(value)]") | |
}, onError: { (error) in | |
print("bSubscribe1 onError [\(error)]") | |
}) | |
bSubject.onNext(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textField | |
.rx | |
.text | |
.asObservable() | |
.bind(to: textField2.rx.text) | |
.disposed(by: disposeBag) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let usrObservable = username.rx | |
.text | |
.orEmpty | |
.asObservable() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let usr = username.rx | |
.text | |
.orEmpty | |
.asObservable() | |
.map { (str)-> Bool in | |
return str.characters.count > 4 | |
} | |
let pwd = password.rx | |
.text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loginFailure() { | |
username.text = "" | |
password.text = "" | |
loginBtn.isEnabled = (username.length > 4) && (password.length > 4) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loginFailure() { | |
username.text = "" | |
password.text = "" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func onTextChanged() { | |
loginBtn.isEnabled = (username.length > 4) && (password.length > 4) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textField | |
.rx //** <--- สำคัญมาก | |
.text | |
.orEmpty | |
.asObservable() | |
.subscribe(onNext: { (str) in | |
print("TextField1 str: [\(str)]") | |
}) | |
.disposed(by: disposeBag) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIDevice.rx.orientation | |
.filter { value in | |
return value != .landscape | |
} | |
.map { _ in | |
return "Portrait is the best!" | |
} | |
.subscribe(onNext: { (string) in | |
showAlert(text: string) | |
}) |