adrielcafe / voyager

🛸 A pragmatic navigation library for Jetpack Compose
https://voyager.adriel.cafe
MIT License
2.55k stars 130 forks source link

Compose Web Support? #74

Open ScottPierce opened 2 years ago

ScottPierce commented 2 years ago

Any plans for Compose Web Support? The big thing about navigating with web is browser url / paths need to be supported.

fmasa commented 2 years ago

Could we split it into two steps?

beyondeye commented 2 years ago

@ScottPierce @fmasa I have completed adding Compose Web support to my fork of voyager, compose_bloc, in js_platform_support branch. I did not merge yet to main because I am still doing some tests. Now about adding navigation based on url/paths, do you have some ideas of the kind of API you would like? I was thinking of implementing an api similar to one the most popular flutter libraries: auto_route or go_router. What do you think?

ScottPierce commented 2 years ago

So I think an important part of this is the String / path based navigation. It needs to integrate well for web. In addition though, I think it has benefits beyond just web for other platforms as well. One of the reasons Google has pushed String based navigation for Android, especially in large projects, is its ability to remove at least one layer, and in some case, 2 layers, from build dependency trees, speeding up build times for very large projects.

Typically for applications, when features are developed and compiled independently of one another, there needs to be a gradle module that depends on all the features, and actually creates the navigation tree so they can navigate to one another via Strings. Android has worked around this via reflection + the Android Manifest. The first iteration doesn't need to implement this, but ideally it'd allow for something like this to be implemented in the future (via compiler plugins or perhaps KSP).

Also, once you allow String based navigation, you are 80% of the way there to deep linking. Whatever String based navigation voyager supports for web, it should also support multiplatform deep linking.

beyondeye commented 2 years ago

@ScottPierce. Thank you for your feedback. It was very helpful. I will start working on string/path based navigation and update about my progress.

ScottPierce commented 2 years ago

@adrielcafe It'd be nice to get official support for web and string based navigation in the main Voyager project.

beyondeye commented 2 years ago

@ScottPierce @fmasa Hi all I have completed implementation of path-based navigation in version 0.13.0 of compose_bloc see the documentation here It would be very helpful if you could give me some feedback

ScottPierce commented 2 years ago

@beyondeye I'm looking into this now since @adrielcafe has been non-responsive. I'm trying to understand the vision here. Why is it part of compose_bloc, instead of a fork, or even an additional library that sits on top of voyager?

beyondeye commented 2 years ago

Good question. When I started working on compose_bloc, my idea was to actually make it an additional library on top of voyager. But voyager development was stale, with several outstanding bugs (related to lifecycle management), so I decided to incorporate a fork of voyager with bugs fixes and improvement inside compose_bloc, with the intention to merge back the code in voyager eventually or at least a part of it. I would like to hear what are @adrielcafe intentions for the future of the project. I think that there are several good design ideas in voyager, but it is falling behind other projects like decompose because it is not maintained, for example in fields like support for web or native platforms. Now speaking specifically about the web platform, lately I have incorporated a fork of routing-compose in compose_bloc. In this case the reason is because I don't agree with the design decision of the author of routing-compose to integrate routing with the composition. I know that this is the way it is done in the original navigation library for compose for Android, but I think that it creates an unnecessary coupling between app logic and ui. I discussed about this with routing-compose author but he prefers it that way.

ScottPierce commented 1 year ago

@beyondeye It looks like the library maintainer is accepting PRs now.

DevSrSouza commented 1 year ago

HI @ScottPierce, A colleague of mine start a routing library, we first tough bring directly to voyager, but after discussing we plan to it be fully multiplatform and generic and also support voyager.

https://github.com/programadorthi/kotlin-routing

We soon should have the first release there, this would bring Path Routing to Voyager.

ScottPierce commented 1 year ago

Already using it. Thanks!