Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add early continue for for of routes if no startPageEvent #2

Merged
merged 3 commits into from
Sep 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions src/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,23 @@ forward({

for (const { component } of routes) {
const startPageEvent = getStart(component);

if (startPageEvent) {
const matchedRoute = sample(routesMatched, sessionLoaded).filterMap(
({ routes, query }) => {
const route = routes.find(routeWithEvent(startPageEvent));
if (route) return { route, query };
return undefined;
},
);

forward({
from: matchedRoute,
to: startPageEvent.prepend(({ route, query }) => ({
params: route.match.params,
query,
})),
});
}
if (!startPageEvent) continue;

const matchedRoute = sample(routesMatched, sessionLoaded).filterMap(
({ routes, query }) => {
const route = routes.find(routeWithEvent(startPageEvent));
if (route) return { route, query };
return undefined;
},
);

forward({
from: matchedRoute,
to: startPageEvent.prepend(({ route, query }) => ({
params: route.match.params,
query,
})),
});
}

sample({
Expand Down