summaryrefslogtreecommitdiff
path: root/bs5/universal/js/ClientRouter.re
blob: 40083c23cdfdcd4761421854752703c212a1a0e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
type t = Router.t(Fetch.Response.t);

external navigate: string => unit = "window.__navigate";
external useAction:
  (string, string) => ((Router.payload, Router.location, unit) => unit, bool) =
  "window.__useAction";

let useRouter: unit => t =
  () => {
    {
      location: Router.initialLocation,
      navigate: str => {
        navigate(Router.locationToString(str));
      },
      useAction: (endpoint, method) => {
        useAction(endpoint, method);
      },
      refresh: str => {
        Js.log(str);
      },
    };
  };