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

Make it easier to implement a ComponentWithValue #73

Merged
merged 3 commits into from
Nov 14, 2023
Merged

Conversation

JD557
Copy link
Owner

@JD557 JD557 commented Nov 14, 2023

New components implemented on top of ComponentWithValue are a bit of a pain to implement, and one of the reasons is that pretty much all implementations add with value.get.

This PR changes it so that ComponentWithValue is implemented with a render(value: Ref[T]): Component[Unit] (applyRef basically calls this and returns the Ref in the end).

It also adds a Ref#modifyIf helper method, as one of the pain points was the amount of code that uses something akin to if (condition) value.modify(f).
Instead of forcing users to write if (condition) value.modify(f) else value, they can just use this new helper.

@JD557 JD557 added this to the 0.1.5 milestone Nov 14, 2023
@JD557 JD557 merged commit 1b9f217 into master Nov 14, 2023
4 checks passed
@JD557 JD557 deleted the ref-modify-if branch November 14, 2023 17:02
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.

None yet

1 participant