Hi, is there a way to convert an optional to a lens?
For example when I do: MyModel.list.index(Index.list(), i), it I knot that the list contains that item?
s
simon.vergauwen
02/11/2024, 11:00 AM
No, that would be an unsafe operation. Could you provide more details on your use-case?
m
Mateu
02/13/2024, 6:37 PM
I use lenses for retrieving and editing the state of a Compose form.
This state can contain a list of subforms (substates).
I've created some inputs that receive a lens as a param and are able to update the state according to the lens and the parent lens if is a nested form. However, in the case of the list I have an optional not a lens. I need somehow to unify this.
The idea is that I will do something like:
model.list.eachIndexed{i,v ->
val parentLens = Model.list.index(Index.list(),i)
myInput(parentLens, SubModel::prop...)
}