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

Create event lambdas when property is set #47

Merged
merged 1 commit into from
Apr 10, 2021

Conversation

JakeWharton
Copy link
Member

This has two nice effects. The first is that it defers a bunch of lambda creation until needed. If you toggle an event property we will create two lambda instances instead of one, but that should be rare. The second advantage is that likely makes the widget interface viable as an indirection the generated compose code can talk through. This will enable compose to talk directly to widgets (#14) or produce diffs. Or perhaps produce schema instances for testing (#1).

This has two nice effects. The first is that it defers a bunch of lambda creation until needed. If you toggle an event property we will create two lambda instances instead of one, but that should be rare. The second advantage is that likely makes the widget interface viable as an indirection the generated compose code can talk through. This will enable compose to talk directly to widgets or produce diffs. Or perhaps produce schema instances for testing.
Comment on lines +82 to +90
3 -> {
val onClick: (() -> Unit)? = if (diff.value as Boolean) {
val event = Event(diff.id, 3, null);
{ events(event) }
} else {
null
}
onClick(onClick)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the core change

@JakeWharton JakeWharton merged commit 7664dbe into trunk Apr 10, 2021
@JakeWharton JakeWharton deleted the jw/event-sink/2021-04-09 branch April 10, 2021 00:16
Copy link
Collaborator

@swankjesse swankjesse left a comment

Choose a reason for hiding this comment

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

Neato.

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

3 participants