Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Proposal : Linking API #56

Closed
Closed
@Freddy03h

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

type routeName = string
type rec pathConfig = {
 path?: string,
 exact?: bool,
 initialRouteName?: routeName,
 screens?: screens,
}
and screens = Js.Dict.t<pathConfig>
type config = {
 initialRouteName?: routeName,
 screens: screens,
}
type t = {
 enabled?: bool,
 prefixes: array<string>,
 config?: config,
}
type routeNameAndConfig = (routeName, pathConfig)
let makeScreens = (screens: array<routeNameAndConfig>): screens => screens->Js.Dict.fromArray

Example

let options = {
 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /