Hi, is there a way to convert an optional to a len...
# arrow
m
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
No, that would be an unsafe operation. Could you provide more details on your use-case?
m
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...) }