Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

302
Vistas
How to implement shouldChangeTextIn the RxSwift way

Is there a way to implement the shouldChangeTextIn UITextView's delegate method in RxSwift way? My goal is to limit the text input of the user. I just have this:

    self.textView.rx.text
        .orEmpty
        .scan("") { (previous, new) -> String in
            return new.count > 254 ? previous : new
        }
        .bind(to: self.viewModel.notes)
        .disposed(by: self.disposeBag)

This is for data, but I don't know how to prevent the further input after 254 count.

I also found RxTextViewDelegateProxy but I'm not sure too how to use it.

let rxTVDelegateProxy = RxTextViewDelegateProxy(textView: self.textView)
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Try this:

       textView.rx.text.orEmpty
        .scan("") { (previous, new) -> String in

            return new.count < 254 ? new : previous ?? String(new.prefix(254))
        }
        .bind(to: textView.rx.text)
        .disposed(by: disposeBag)
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda