Skip to content
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

Closes #150; Concise alternative to FieldsWhere.kt #163

Merged
merged 2 commits into from Jan 4, 2022

Conversation

jayasuryat
Copy link
Contributor

This PR brings in a more concise and maintainable way of doing what contacts.core.util.FieldsWhere.kt extensions are doing.

More details are discussed in here #162 and here #150.

TLDR: There were a bunch of handwritten extension methods on concrete Field and FieldSet types, which enabled more idiomatic and DSLesk API surface. Now expressing all of those methods using Kotlin magic (invoke operator function overloads and lambdas) in a more concise way.

As discussed prior, the new extensions are added in the contacts.core.Where.kt file and the contacts.core.util.FieldsWhere.kt file has been removed in favor of the new extensions.

@vestrel00 vestrel00 self-requested a review January 4, 2022 01:26
@vestrel00 vestrel00 added code quality This is about code quality and static analysis enhancement New feature or request refactor This may involve a refactor labels Jan 4, 2022
* operators on multiple fields of a [FieldSet].
*/
inline operator fun <T : Field, FS : FieldSet<T>> FS.invoke(where: FS.() -> Where<T>): Where<T> =
where(this)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10/10 implementation and documentation. Thank you!

@@ -1,570 +0,0 @@
@file:Suppress("FunctionName")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good thing that I asked about this on Reddit! You have literally reduced ~500 lines of code down to 2 lines. I have no words. I learned something from this! I don't know everything about Kotlin magic!

I have given you a gold medal for this. Thank you ❤️

Screen Shot 2022-01-03 at 3 32 31 PM

I want to give you 50,000 points but I don't have money 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true, sometimes seemingly random things lead us to some interesting places and situations, this time it was Reddit.

Thank you so much for your appreciation. You are too kind and wholesome.
I'm already chuffed to bits with your responses, they mean a whole lot more to me than Reddit awards. But still, thank you for taking time out and showing appreciation the way you did, be it on Reddit or on GitHub.

This was my first Open Source contribution (other than my own projects), I'm glad it worked out for both of us the way it did ❤️.

@vestrel00 vestrel00 added this to In review in General maintenance Jan 4, 2022
@vestrel00 vestrel00 merged commit b865832 into vestrel00:main Jan 4, 2022
@vestrel00 vestrel00 moved this from In review to Done in General maintenance Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality This is about code quality and static analysis enhancement New feature or request refactor This may involve a refactor
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants