Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed Jul 20, 2024
1 parent 2e65a37 commit c195ae5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 39 deletions.
14 changes: 8 additions & 6 deletions packages/rescript-relay-router/src/RelayRouter.res
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,14 @@ module Router = {
~pathParams=match.params,
~queryParams,
~location,
)->Js.Promise.then_(
assetsToPreload => {
assetsToPreload->Belt.Array.forEach(a => a->preloadAsset(~priority))
Js.Promise.resolve()
},
_,
)->(
Js.Promise.then_(
assetsToPreload => {
assetsToPreload->Belt.Array.forEach(a => a->preloadAsset(~priority))
Js.Promise.resolve()
},
_,
)
)
}, ~priority)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ let doLoadRouteRenderer = (
let promise = loadFn()
loadedRouteRenderers->Belt.HashMap.String.set(routeName, Pending(promise))

promise->Js.Promise.then_(routeRenderer => {
loadedRouteRenderers->Belt.HashMap.String.set(routeName, Loaded(routeRenderer))
Js.Promise.resolve()
}, _)
promise->(Js.Promise.then_(routeRenderer => {
loadedRouteRenderers->Belt.HashMap.String.set(routeName, Loaded(routeRenderer))
Js.Promise.resolve()
}, _))
}

// This does a bunch of suspense/React gymnastics for kicking off code
Expand All @@ -80,20 +80,20 @@ let preloadCode = (
}

switch loadedRouteRenderers->Belt.HashMap.String.get(routeName) {
| None | Some(NotInitiated) => loadRouteRenderer()->Js.Promise.then_(() => {
switch loadedRouteRenderers->Belt.HashMap.String.get(routeName) {
| Some(Loaded(routeRenderer)) => routeRenderer->apply->Js.Promise.resolve
| _ =>
raise(
Route_loading_failed(
"Invalid state after loading route renderer. Please report this error.",
),
)
}
}, _)
| Some(Pending(promise)) => promise->Js.Promise.then_(routeRenderer => {
routeRenderer->apply->Js.Promise.resolve
}, _)
| None | Some(NotInitiated) => loadRouteRenderer()->(Js.Promise.then_(() => {
switch loadedRouteRenderers->Belt.HashMap.String.get(routeName) {
| Some(Loaded(routeRenderer)) => routeRenderer->apply->Js.Promise.resolve
| _ =>
raise(
Route_loading_failed(
"Invalid state after loading route renderer. Please report this error.",
),
)
}
}, _))
| Some(Pending(promise)) => promise->(Js.Promise.then_(routeRenderer => {
routeRenderer->apply->Js.Promise.resolve
}, _))
| Some(Loaded(routeRenderer)) =>
Js.Promise.make((~resolve, ~reject as _) => {
resolve(apply(routeRenderer))
Expand Down Expand Up @@ -284,22 +284,22 @@ let makePrepareAssets = (~loadedRouteRenderers, ~prepareDisposeTimeout): prepare

switch loadedRouteRenderers->Belt.HashMap.String.get(routeName) {
| None | Some(NotInitiated) =>
let preparePromise = loadRouteRenderer()->Js.Promise.then_(() => {
switch loadedRouteRenderers->Belt.HashMap.String.get(routeName) {
| Some(Loaded(routeRenderer)) => doPrepare(routeRenderer)->Js.Promise.resolve
| _ =>
raise(
Route_loading_failed(
"Route renderer not in loaded state even though it should be. This should be impossible, please report this error.",
),
)
}
}, _)
let preparePromise = loadRouteRenderer()->(Js.Promise.then_(() => {
switch loadedRouteRenderers->Belt.HashMap.String.get(routeName) {
| Some(Loaded(routeRenderer)) => doPrepare(routeRenderer)->Js.Promise.resolve
| _ =>
raise(
Route_loading_failed(
"Route renderer not in loaded state even though it should be. This should be impossible, please report this error.",
),
)
}
}, _))
preparedRef.contents = Pending(preparePromise)
| Some(Pending(promise)) =>
let preparePromise = promise->Js.Promise.then_(routeRenderer => {
doPrepare(routeRenderer)->Js.Promise.resolve
}, _)
let preparePromise = promise->(Js.Promise.then_(routeRenderer => {
doPrepare(routeRenderer)->Js.Promise.resolve
}, _))
preparedRef.contents = Pending(preparePromise)
| Some(Loaded(routeRenderer)) =>
let _ = doPrepare(routeRenderer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ let loadViteManifest = path => {
}

let writeRouterManifest = (path, manifest: RelayRouter.Manifest.t) => {
manifest->RelayRouter.Manifest.stringifyWithSpace(_, 2)->(writeFileSync(path, _, "utf-8"))
manifest->(RelayRouter.Manifest.stringifyWithSpace(_, 2))->(writeFileSync(path, _, "utf-8"))
}

let transformManifest = (inPath, outPath) => {
Expand Down

0 comments on commit c195ae5

Please sign in to comment.