We will use the map function on the control property to filter out values as follows:
usernameTextField.rx.text.map { $0 ?? "" }
$0 represents the first variable, and if this is nil, we will return an empty string and pass that through to bind the returned value to the ViewModel's variable as desired by making use of the bindTo operator:
usernameTextField.rx.text.map { $0 ?? "" .bind(to: loginViewModel.username)
This will simply tell the ViewModel that the input of this text field has changed. The preceding line of code might throw a warning about an unused value.
_ = usernameTextField.rx.text.map { $0 ?? "" } .bind(to: loginViewModel.username) ...