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

Initialize Bridge instances within the library #10

Merged
merged 2 commits into from
Apr 6, 2023
Merged

Conversation

jayohms
Copy link
Collaborator

@jayohms jayohms commented Apr 6, 2023

This allows the library to take control of create/destroying Bridge instances. A Bridge has a 1:1 relationship with a WebView, so whenever an app creates/uses a new WebView instances, it must call:

Bridge.initialize(webView)

From there, the library will create a new internal Bridge instance if one doesn't already exist for the WebView instance. This change makes it much easier for apps using turbo-android, since the WebView instance is swapped between destinations and maintaining a reference to the corresponding Bridge instance is no longer an app concern.

…lize the bridge with a WebView instance through Bridge.initialize(webView).
* main:
  Rename BridgeDestination functions so they're more clear and consistent
  Use a property to enable debug logging instead of a function
  Log an event if a message fails to send
  Use .getOrPut() to get or create new component instances

# Conflicts:
#	strada/src/test/kotlin/dev/hotwire/strada/BridgeDelegateTest.kt
@jayohms jayohms requested a review from mbarta April 6, 2023 14:49
Copy link

@mbarta mbarta left a comment

Choose a reason for hiding this comment

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

Nice, these changes give us a neat public API for bridge initialisation 👍

@jayohms jayohms merged commit 326923d into main Apr 6, 2023
@jayohms jayohms deleted the bridge-initialize branch April 6, 2023 15:21
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