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

Arrow Optics ❤️ Compose #3299

Merged
merged 27 commits into from
Jan 23, 2024
Merged

Arrow Optics ❤️ Compose #3299

merged 27 commits into from
Jan 23, 2024

Conversation

serras
Copy link
Member

@serras serras commented Nov 15, 2023

These are a few utilities which help working with MutableState (as in Compose) using optics.

@serras serras self-assigned this Nov 15, 2023
kotlin {
explicitApi()

jvm {
Copy link
Member

Choose a reason for hiding this comment

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

Off-topic: @serras how do you feel about doing this explicitly in Arrow instead of relying on the arrowGradleConfig?

Arrow Gradle Config came to live because of publishing, and I've in favor of replacing Arrow Gradle Config Nexus/Publish with https://github.com/vanniktech/gradle-maven-publish-plugin. I've tried it on a couple of my projects and it works better as what we have whilst supporting the same style of configuration we currently use.

Copy link
Member Author

Choose a reason for hiding this comment

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

That sounds great (although having to define all the targets on each project seems tiresome). Maybe another thing to do in the arrow-2 branch?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe another thing to do in the arrow-2 branch?

Was wondering if we could do something interesting in buildSrc or something where we can define some top-level functions to avoid all the repetitive boilerplate. arrow-2 sounds good! Definitely not for 1.2.2 😅

Copy link
Member

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

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

Awesome stuff @serras! 🙌

Copy link
Contributor

github-actions bot commented Nov 15, 2023

Kover Report

File Coverage [100.00%]
arrow-libs/optics/arrow-optics-compose/src/commonMain/kotlin/arrow/optics/Copy.kt 100.00%
Total Project Coverage 54.09%

this@optic.collect { collector.emit(g.get(it)) }

override val replayCache: List<A>
get() = this@optic.replayCache.map { g.get(it) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Always contains single element.

Suggested change
get() = this@optic.replayCache.map { g.get(it) }
get() = listOf(value)

Copy link
Member Author

Choose a reason for hiding this comment

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

I would prefer to keep this implementation, since it makes it more clear that we are just reusing the replayCache from the nested version.

get() = this@optic.subscriptionCount

override val replayCache: List<A>
get() = this@optic.replayCache.map { lens.get(it) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above 🙏

Copy link
Member

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

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

Looks great @serras, thank you for this great work! I just have one small thought.

@serras serras merged commit 358a115 into main Jan 23, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants