Skip to content

Commit

Permalink
Delay Planner.js import until first plan is calculated
Browse files Browse the repository at this point in the history
  • Loading branch information
tuukka committed May 27, 2020
1 parent 639d67c commit 304a8ac
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/planner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
GeoJsonProperties,
} from "geojson";

import { Planner } from "./planner-config";
// "./planner-config" (and PlannerJS) is imported dynamically by calculatePlan

import { ElementWithCoordinates } from "./overpass";

Expand Down Expand Up @@ -206,11 +206,15 @@ export function geometryToGeoJSON(
};
}

export default function calculatePlan(
export default async function calculatePlan(
origin: [number, number],
targets: Array<ElementWithCoordinates>,
callback: (f: FeatureCollection) => void
): void {
): Promise<void> {
const { Planner } = await import(
/* webpackChunkName: "planner-config" */
"./planner-config"
);
targets.forEach((target) => {
const planner = new Planner();
// XXX setProfileID requires URL to start with scheme, so guess
Expand Down

0 comments on commit 304a8ac

Please sign in to comment.