Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork31
Closed
Description
Linking API
For my project I created a linking API but I'm far from zero cost binding, since ReScript 10 and optional record attribute, it's seems less shitty and I think it's cool to discuss to have experts opinions about it.
Proposal
typerouteName=stringtyperecpathConfig= {path?:string,exact?:bool,initialRouteName?:routeName,screens?:screens,}andscreens=Js.Dict.t<pathConfig>typeconfig= {initialRouteName?:routeName,screens:screens,}typet= {enabled?:bool,prefixes:array<string>,config?:config,}typerouteNameAndConfig= (routeName,pathConfig)letmakeScreens= (screens:array<routeNameAndConfig>):screens=>screens->Js.Dict.fromArray
Example
letoptions= {prefixes: [WebConst.origin],config: {initialRouteName:"app",screens: [ ("app", {screens: [ ("news", {screens: [("newsList", {path:""})]->makeScreens}), ("planning", {screens: [ ("planningNav", {screens: [ ("planningNewList", {path:"planning/news"}), ("planningList", {path:"planning"}), ]->makeScreens, }, ), ]->makeScreens, }, ), ("catalogue", {screens: [ ("catalogueNav", {screens: [ ("seriesList", {path:"series"}), ("authorsList", {path:"authors"}), ("publishersList", {path:"publishers"}), ]->makeScreens, }, ), ]->makeScreens, }, ), ]->makeScreens, }, ), ("modalNav", {screens: [ ("volumeDetail", {path:"volumes/:id"}), ("editionDetail", {path:"editions/:id"}), ("serieDetail", {path:"series/:id"}), ("publisherDetail", {path:"publishers/:id"}), ("authorDetail", {path:"authors/:id"}), ]->makeScreens, }, ), ("collectionPublic", {initialRouteName:"collectionPublicNav",path:"user/:username",screens: [ ("collectionPublicNav", {screens: [ ("collectionPublicList", {path:"collection"}), ("planningPersoPublicList", {path:"planning"}), ("missingPublicList", {path:"missing"}), ("wishPublicList", {path:"wish"}), ]->makeScreens, }, ), ("collectionPublicEdition", {path:"edition/:editionId"}), ]->makeScreens, }, ), ]->makeScreens, },}
Metadata
Metadata
Assignees
Labels
No labels