hotwired / turbo-android

Android framework for making Turbo native apps
MIT License
408 stars 51 forks source link

Expose TurboSession allowing use outside the module #254

Closed Fryzu closed 1 year ago

Fryzu commented 1 year ago

Fixes: #245

Summary

Hello πŸ‘‹ I am software engineer working for Software Mansion. Together with @pfeiffer we are working on React Native support for Turbo πŸš€. Our goal is to add support for React Native hybrid apps on both iOS and Android for turbo enabled websites. Under the hood we use both Turbo Android and Turbo iOS. We have an almost ready version of our library, please check out our repo react-native-turbo-webview.

What's the problem?

iOS implementation with Turbo iOS was fairly easy, but the way Turbo Android depends on Android Navigation, makes the Android-implementation less straightforward. ​ Turbo Android doesn't leave much freedom for our implementation and It is impossible to use it without the Android Navigation which we can't use in the case of React Native. We are forced to use session class directly, sadly it is not easy as it is marked with internal visibility modifiers. ​ We solved this problem in forked repo, at the moment we are using a patched version of turbo-android for the PoC. ​ Removing internal modifiers makes it possible to use the package similarly to Turbo iOS and unifies the API. I do not see any reasons against the removal of modifiers but I am open to discussion over alternative solutions.

Changes

dhh commented 1 year ago

@jayohms can you have a look here?

jayohms commented 1 year ago

Thank you for the PR, however this isn't a suitable change for the Android library. Proper internal/public separation is important to maintain the library long-term. The Android library is quite deliberate in providing fully native navigation and wasn't designed to use the TurboSession independently.

While the iOS library may work for your needs, we have plans going forward for it to be more opinionated in providing out-of-the-box navigation and presentation between ViewControllers.

All the source code in turbo-android is available for your use to fork/copy and provide a good React Native experience β€” and since it sounds like you're handling the navigation aspects, you shouldn't need to bring too much over in your own library.