You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to follow the docs to create a bridge component, but i think the component wasn't loading because the default user agent is sending an empty list of components (bridge-components: [];)
If I understand correctly, hotwire-native-bridge checks that the list is not empty here to decide if the component should load.
If the user agent is overridden with something like Hotwire.config.userAgent = "MyApp; ${Hotwire.config.userAgentSubstring()}", the user agent now includes the right bridge-compoennts, and the component loads correctly.
Not sure if this is a bug or if i missed something in the docs, but it felt like the default userAgent should just work.
Was also able to reproduce this int he demo app, by commenting out the custom userAgent line here. After doing this, the bridge components stop working
The text was updated successfully, but these errors were encountered:
I had this same problem for a bit. The hotwire-native-bridge does expect that the array be non-empty. Which kind of makes sense if you think about it. If there are not bridge components registered then there is no reason to even load them on the client and waste potential resources. The client is telling the rails app "Hey, I can handle these bridge components". If your app is not using bridge components, then there's no reason for it to connect the stimulus controllers.
I can see why you'd want it to work by default, so maybe setting the Hotwire.config.userAgent by default to the substring might suffice?
yeah, i think it makes sense that hotwire-native-bridge requires a non-empty array to initialize the components.
What was unexpected to me was that hotwire-native-android wouldn't send these components by default, even after registering the bridge components with Hotwire.registerBridgeComponents
Looking at this code
funuserAgentSubstring(): String {
val components = registeredBridgeComponentFactories.joinToString("") { it.name }
return"Turbo Native Android; bridge-components: [$components];"
}
var userAgent:String= userAgentSubstring()
it made me think the intention was that, by default, the userAgent should include all the registered bridge components, but maybe this default is being evaluated before the components are registered, so the array ends up being empty?
I was trying to follow the docs to create a bridge component, but i think the component wasn't loading because the default user agent is sending an empty list of components (
bridge-components: [];
)If I understand correctly,
hotwire-native-bridge
checks that the list is not empty here to decide if the component should load.If the user agent is overridden with something like
Hotwire.config.userAgent = "MyApp; ${Hotwire.config.userAgentSubstring()}"
, the user agent now includes the right bridge-compoennts, and the component loads correctly.Not sure if this is a bug or if i missed something in the docs, but it felt like the default userAgent should just work.
Was also able to reproduce this int he demo app, by commenting out the custom userAgent line here. After doing this, the bridge components stop working
The text was updated successfully, but these errors were encountered: