Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!