-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mapNullable
function to Store
s and Inspector
s
#928
Conversation
e10bdd0
to
c4be134
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the remarked question first.
internal fun <T> defaultLens(id: String, default: T): Lens<T?, T> = object : Lens<T?, T> { | ||
override val id: String = id | ||
internal fun <T> mapToNonNullLens(default: T): Lens<T?, T> = object : Lens<T?, T> { | ||
override val id: String = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure that this is a good idea? If the value of a Lens's id
is an empty String, we do not modify the path
like for formatting lenses.
How was this function used before?
Does this maybe affect the validation process for generated lenses? Have you checked this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! The parameter has never been used, though. I manually checked every occurrence and made sure it's an empty String. As the function is internal, we can be sure that it is not breaking as well 👍🏻
I think the new function is also missing in the docs: |
c4be134
to
01a759d
Compare
This PR adds a
mapNullable
function toStore
s andInspector
s that works as the reverse equivalent formapNull
.The function can be used to map non-nullable Stores/Inspectors to nullable ones as follows:
Closes #927