Skip to content

Instantly share code, notes, and snippets.

@jordwalke
Created October 17, 2017 03:25
Show Gist options
  • Save jordwalke/7debcba08817cb479aa0ed71f9bfa4d4 to your computer and use it in GitHub Desktop.
Save jordwalke/7debcba08817cb479aa0ed71f9bfa4d4 to your computer and use it in GitHub Desktop.
Routes.re
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