Simplify initial app setup with a SessionConfiguration
#24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR introduces a handful of changes with the goal of reducing the complexity of starting a new app. It allows an app setup to take place across fewer files and removes the need to subclass
SessionNavHostFragment
for everySession
instance in an app.The
HotwireActivity
interface has been updated to require the app provide a list ofSessionConfiguration
instances, which maps toSessionNavHostFragment
instances present in theActivity
.Now, to spin up a new app all that's required is to update the
activity_main.xml
file to include aSessionNavHostFragment
in the layout:And then implement the
HotwireActivity
interface in your mainActivity
:That's it!
This PR also:
Hotwire.appUrl
configuration concept. It was flawed, in that each session url should be independent from each other and a global app url would prevent sessions with independent sub/domains.Route
interface to look at theSessionConfiguration
instance when determine if a route matches, instead of the globalHotwire.appUrl
.SessionNavHostFragment
instances with theHotwireActivityDelegate
when they're inflated/created. This previously required manual registration if you had more than oneSessionNavHostFragment
instance.