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

Rename BridgeComponent APIs #19

Merged
merged 3 commits into from
Aug 7, 2023
Merged

Rename BridgeComponent APIs #19

merged 3 commits into from
Aug 7, 2023

Conversation

jayohms
Copy link
Collaborator

@jayohms jayohms commented Aug 7, 2023

This adds clarity to the BridgeComponent APIs. Components don't merely send messages: they receive messages from the web and reply to those messages (optionally with new event/data).

class TestComponent : BridgeComponent {
    override fun onReceive(message: Message) {
        // handle message
    }

    fun handleSomeUserAction(message) {
        replyWith(message.replacing(jsonData = myNewData))
    }
}

This also marks the Message constructor as internal so apps cannot create new instances themselves. They must reply to existing messages using the .replacing(event, data) method to modify the properties when replying back to the web.

…ot create new instances themselves. Messages must be replied to using the .replacing() mehod to modify the event/data.
@jayohms jayohms requested a review from svara August 7, 2023 14:23
Copy link

@svara svara left a comment

Choose a reason for hiding this comment

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

Nice improvements! 👍🏻

@jayohms jayohms merged commit 196648d into main Aug 7, 2023
1 check passed
@jayohms jayohms deleted the rename-component-apis branch August 7, 2023 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants