hotwired / hotwire-native-site

Hotwire Native
5 stars 2 forks source link

Remove Hotwire bridge component registration? #9

Closed jayohms closed 4 months ago

jayohms commented 4 months ago

On the iOS Getting Started page, we show this code block:

import Hotwire
import UIKit

let rootURL = URL(string: "https://turbo-native-demo.glitch.me")!

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    var window: UIWindow?

    private let navigator = Navigator()

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        Hotwire.registerStradaComponents([])
        window?.rootViewController = navigator.rootViewController
        navigator.route(rootURL)
    }
}

Can we completely remove the empty Hotwire.registerStradaComponents([]) line? If you're not registering any bridge components the default (empty) configuration should work out-of-the-box and we can reveal this code in the Bridge Components section instead.

joemasilotti commented 4 months ago

Ha, I was thinking this same thing a few sleepless nights ago!

The tricky part is that this currently acts to bootstrap Hotwire Native. It sets the default view controller, the user agent, etc. But I think that that is not cruft, left around from when we had more clear separation between the Hotwire wrapper, Turbo, and Strada.

I think I can refactor this to only have the call required when you're actually using bridge components. I'll report back.

jayohms commented 4 months ago

Ah, so currently the registerBridgeComponents() call is doing more behind the scenes? If so, yeah we should fix that so those pieces aren't a side effect of another optional, unrelated call.

On the Android side, we have defaults setup for those automatically:

joemasilotti commented 4 months ago

Now that we only have one library that was much cleaner then I expected!

Closed via #12 and Hotwire Native iOS #18.