You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose that i'm writing my own View class, that represents editable field and contains EditText tv_input inside:
class EditTextIconItemView : LinearLayout {
fun setInputText(text: String?) {
with (tv_input) {
setText(text)
setCharsCount(text?.length ?: 0)
setSelection(text?.length ?: 0)
}
}
fun setCharsCount(count: Int) {
tv_chars_count?.text = "$count/$MAX_LENGTH"
}
}
I'd like to delegate textChanges() to that internal EditText tv_input, so i'm writing the following code in my custom EditTextIconItemView:
fun EditTextIconItemView.textChanges() =
tv_input.textChanges().doOnNext { setCharsCount(it.length) }
That works well, but now i want my client code to actually skip initial value, so in client code i have:
val et = EditTextIconItemView()
et.textChanges().skipInitialValue().subscribe { ... }
This requires me to explicitly specify the return type in EditTextIconItemView for textChanges():
fun EditTextIconItemView.textChanges(): InitialValueObservable<CharSequence> =
tv_input.textChanges().doOnNext { setCharsCount(it.length) }
But this won't compile since doOnNext returns Observable which cannot be cast to InitialValueObservable.
But i actually don't want the client code to handle that side effect and set up chars count on that View, this is the responsibility of EditTextIconItemView itself. But i' like to still be able to tell, whether to skip initial value or not on client's side.
How could i make it work?
Thank You!
The text was updated successfully, but these errors were encountered:
Suppose that i'm writing my own View class, that represents editable field and contains EditText tv_input inside:
I'd like to delegate textChanges() to that internal EditText tv_input, so i'm writing the following code in my custom EditTextIconItemView:
That works well, but now i want my client code to actually skip initial value, so in client code i have:
This requires me to explicitly specify the return type in EditTextIconItemView for textChanges():
But this won't compile since doOnNext returns Observable which cannot be cast to InitialValueObservable.
But i actually don't want the client code to handle that side effect and set up chars count on that View, this is the responsibility of EditTextIconItemView itself. But i' like to still be able to tell, whether to skip initial value or not on client's side.
How could i make it work?
Thank You!
The text was updated successfully, but these errors were encountered: