Created
October 17, 2017 03:25
-
-
Save jordwalke/7debcba08817cb479aa0ed71f9bfa4d4 to your computer and use it in GitHub Desktop.
Routes.re
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type RouteParams = {type t; let makeParams: unit => t;}; | |
module type RouteIntf = {type t; type params; let getParams: t => params;}; | |
module MakeRoute (Params: RouteParams) :RouteIntf => { | |
type t = {path: string}; | |
type params = Params.t; | |
let getParams _ => Params.makeParams (); | |
}; | |
type navigationState = { | |
currentIndex: int, | |
routes: list (module RouteIntf) | |
}; | |
module MyRoute = | |
MakeRoute { | |
type t = string; | |
let makeParams () => "hi"; | |
}; | |
module YourRoute = | |
MakeRoute { | |
type t = int; | |
let makeParams () => 10; | |
}; | |
let myRoute: (module RouteIntf) = (module MyRoute); | |
let navigationState = [myRoute, myRoute, ((module YourRoute): (module RouteIntf))]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment