46 lines
928 B
TypeScript
46 lines
928 B
TypeScript
import { Component, createEffect, For, onCleanup, Suspense } from 'solid-js';
|
|
|
|
import OlMap from 'ol/Map';
|
|
|
|
import Gpx from '../gpx';
|
|
import {
|
|
createCachedSignal,
|
|
destroyCachedSignal,
|
|
} from '../../workers/cached-signals';
|
|
|
|
interface Props {
|
|
map: () => OlMap | null;
|
|
}
|
|
|
|
export const AllGpxes: Component<Props> = ({ map }) => {
|
|
const params = {
|
|
id: 'gpx',
|
|
method: 'getAllGpxes',
|
|
};
|
|
const allGpxIds = createCachedSignal(params);
|
|
|
|
onCleanup(() => {
|
|
destroyCachedSignal(params);
|
|
});
|
|
|
|
createEffect(() => {
|
|
console.log({ caller: 'AllGpxes', allGpxes: allGpxIds(), map: map() });
|
|
});
|
|
|
|
return (
|
|
// @ts-ignore
|
|
<For each={allGpxIds()}>
|
|
{(gpxId: string) => {
|
|
console.log({ caller: 'AllGpxes / loop', gpxId });
|
|
return (
|
|
<Suspense>
|
|
<Gpx map={map} gpxId={gpxId} />
|
|
</Suspense>
|
|
);
|
|
}}
|
|
</For>
|
|
);
|
|
};
|
|
|
|
export default AllGpxes;
|