Refactoring to implement visualization and edition features.

This commit is contained in:
vdv committed 2023-01-02 17:27:55 +01:00
1 parent 67cfd16efb
commit adc37fef03
11 files changed
+129 -223

No files matched your search

+9 -33
View File
@@ -15,6 +15,10 @@ import getUri from '../../lib/ids';
import Trkseg from '../trkseg';
import VectorSource from 'ol/source/Vector';
import {
createCachedSignal,
destroyCachedSignal,
} from '../../workers/cached-signals';
interface Props {
trkId: string;
@@ -22,42 +26,14 @@ interface Props {
context: any;
}
export const Trk: Component<Props> = ({ vectorSource, trkId, context }) => {
const [trk, setTrk] = createSignal<Trk>();
const [dispatchId, setDispatchId] = createSignal<number>(-1);
const trkCallBack = (error: any, result: any, id?: number) => {
if (error) {
console.error({ caller: 'trkCallBack', error });
} else {
console.log({ caller: 'trkCallBack', result });
setTrk(result);
}
if (id) {
setDispatchId(id);
}
const params = {
id: trkId,
method: 'getTrk',
};
dispatch(
{
action: 'getAndWatch',
params: {
id: trkId,
method: 'getTrk',
},
},
trkCallBack,
true
);
const trk = createCachedSignal(params);
onCleanup(() => {
dispatch({
action: 'cancelWatch',
params: {
id: trkId,
method: 'getTrk',
},
});
cancelDispatch(dispatchId());
destroyCachedSignal(params);
});
createEffect(() => {