Debouncing Map state db persisting
This commit is contained in:
parent
600ce534fe
commit
d1a3e6bf82
|
@ -37,7 +37,7 @@ import Infos, { clickHandler } from '../infos';
|
|||
import GpxDialog from '../gpx-dialog';
|
||||
import GpxRecord from '../gpx-record';
|
||||
import dispatch from '../../workers/dispatcher-main';
|
||||
import { isEqual } from 'lodash';
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
const [getState, setState] = createSignal({
|
||||
lon: 0,
|
||||
|
@ -76,6 +76,11 @@ const Map: Component = () => {
|
|||
|
||||
let target: HTMLDivElement;
|
||||
|
||||
const debouncedDbSetState = debounce((state: any) => {
|
||||
console.log({ caller: 'Map / debouncedDbSetState', state });
|
||||
dispatch({ action: 'setState', params: state });
|
||||
}, 60000);
|
||||
|
||||
createEffect(async () => {
|
||||
console.log({
|
||||
caller: 'Map / setState',
|
||||
|
@ -90,7 +95,7 @@ const Map: Component = () => {
|
|||
rotation: +params.rotation,
|
||||
zoom: +params.zoom,
|
||||
});
|
||||
await dispatch({ action: 'setState', params: getState() });
|
||||
debouncedDbSetState(getState());
|
||||
const map = getMap();
|
||||
|
||||
const layers = map?.getLayers();
|
||||
|
|
Loading…
Reference in New Issue