-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
registering a route with a path, the scheme is redundant #31
Comments
Thanks for your feedback! |
Thanks for your reply!
For the registeration, I think I misunderstand it, the url doesn't require
a scheme when configuring which is great.
Considerable points:
1. Multiple urls for same handler
2. a router can be configured with both scheme and URL. for the
registeration just focus on the path
And I'm thinking if there is a globalRouter could be better? Coz the
instance of router is only available in the SAME space. I can't use the
router in a separated module which could be intergrated in app later.
Thank you
Kohki Miki <[email protected]> 于 2021年2月20日周六 19:29写道:
… Thanks for your feedback!
I have an idea. I'll implement multiple schemes support soon.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABYXELR2KY6XOQ47AICIG3S76FHZANCNFSM4XZUUWCA>
.
|
there should be like a |
I don't agree Crossroad should provide a global router. I think libraries should keep avoiding global states as we can. I expect that AppDelegate has a router and register all routes into that in most use cases. |
Image you get 4 modules, A B C D, you don't want A depends on B, but A use a route Your case is that everything is in a same project. But image there are 100 modules managed by CocoaPods in your project |
Multimodule structures are varied by each project. (how to resolve dependencies between each module, abstraction way, etc...) So I think Crossroad should not provide global routers. By the way, this issue discusses multiple URL scheme support. |
@aelam I tried to implement this feature. First, I'm planning to support multiple schemes( or URLs) for one router. Please moment. |
@aelam I apologize to keep you waiting. I released 4.0.0. Crossroad 4.0.0 supports grouped routes. let customURLScheme: LinkSource = .customURLScheme("pokedex")
let pokedexWeb: LinkSource = .universalLink(URL(string: "https://my-awesome-pokedex.com")!)
let anotherWeb: LinkSource = .universalLink(URL(string: "https://kanto.my-awesome-pokedex.com")!)
let router = try DefaultRouter(accepting: [customURLScheme, pokedexWeb, anotherWeb]) { registry in
// Pokémon detail pages can be opened from all sources.
registry.route("/pokemons/:pokedexID") { context in
let pokedexID: Int = try context.argument(named: "pokedexID") // Parse 'pokedexID' from URL
if !Pokedex.isExist(pokedexID) { // Find the Pokémon by ID
throw PokedexError.pokemonIsNotExist(pokedexID)
}
presentPokedexDetailViewController(of: pokedexID)
}
// Move related pages can be opened only from Custom URL Schemes
registry.group(accepting: [customURLScheme]) { group in
group.route("/moves/:move_name") { context in
let moveName: String = try context.argument(named: "move_name")
presentMoveViewController(for: moveName)
}
group.route("/pokemons/:pokedexID/move") { context in
let pokedexID: Int = try context.argument(named: "pokedexID")
presentPokemonMoveViewController(for: pokedexID)
}
}
} You can share handlers between custom URL schemes and universal links. |
Thanks for your great work! let me check! |
Crossroad/Tests/CrossroadTests/RouterTests.swift
Lines 38 to 60 in 4788906
When we register it's such a trouble to write the scheme all the time when we've declared the scheme for Router!
If you really wan to do so, you should let the same router supports both scheme and http url too!
L53~L58 should be true
considering the http url, that's a pain for registering too
The text was updated successfully, but these errors were encountered: