https://kotlinlang.org logo
u

ursus

06/13/2019, 5:18 AM
hi reduxy folks, I want ask OT but related to the paradigm shift, since Compose is way in the future. If I were to have a Edit text, in proper reduxy way, one should emit a new state state every new char is typed. Which I then in thoery need to set back on the Edit text. If I do that, it visibly lags. Is there a way to make this performant now? (without ©ompose)
g

gildor

06/13/2019, 5:38 AM
now? So you use Android Views for this?
And how exactly you apply those changes? Inflate it each time is obviously too slow
u

ursus

06/13/2019, 6:26 AM
yes android edittext; no inflation, just mutation lf the same instance via edittext.textWatcher -- on every char + apply state.text back to edittext
g

gildor

06/13/2019, 6:28 AM
it should work relatively fast, but may cause problems with selections and cursor position, anyway I don’t think this related to this channel topic or to Kotlin in general
u

ursus

06/13/2019, 6:30 AM
well not sure whether its the edittect.setSelection(state.text.size) or the setText itself, but its unusable, not nicpicking, if you were to try it you'd see
d

david.bilik

06/13/2019, 7:05 AM
Each time I’ve implemented something like this I’ve added some checks to not set the text if it was the same as already presented in EditText .. in that time no cursor of other lags was not there .. but its not ideal, sure
u

ursus

06/13/2019, 7:14 AM
@david.bilik did you compare against previousState.text or if(newState.text != ediText.text.toString())?
d

david.bilik

06/13/2019, 7:15 AM
against edittext itself
2 Views