Refactoring to watch WPT updates.
This commit is contained in:
1 parent
6465a371cb
commit
5829f93c91
5 files changed
+111
-41
No files matched your search
+27
-10
@@ -1,4 +1,9 @@
|
||||
import { Component, createEffect, createResource } from 'solid-js';
|
||||
import {
|
||||
Component,
|
||||
createEffect,
|
||||
createResource,
|
||||
createSignal,
|
||||
} from 'solid-js';
|
||||
|
||||
import dispatch from '../../workers/dispatcher-main';
|
||||
import VectorSource from 'ol/source/Vector';
|
||||
@@ -12,15 +17,27 @@ interface Props {
|
||||
}
|
||||
|
||||
export const Wpt: Component<Props> = ({ vectorSource, wptId: wptId }) => {
|
||||
const [wpt] = createResource(
|
||||
wptId,
|
||||
async () =>
|
||||
await dispatch({
|
||||
action: 'getWpt',
|
||||
params: {
|
||||
id: wptId,
|
||||
},
|
||||
})
|
||||
const [wpt, setWpt] = createSignal<Wpt>();
|
||||
|
||||
const wptCallBack = (error: any, result: any) => {
|
||||
if (error) {
|
||||
console.error({ caller: 'wptCallBack', error });
|
||||
} else {
|
||||
console.log({ caller: 'wptCallBack', result });
|
||||
setWpt(result);
|
||||
}
|
||||
};
|
||||
|
||||
dispatch(
|
||||
{
|
||||
action: 'getAndWatch',
|
||||
params: {
|
||||
id: wptId,
|
||||
method: 'getWpt',
|
||||
},
|
||||
},
|
||||
wptCallBack,
|
||||
true
|
||||
);
|
||||
|
||||
createEffect(() => {
|
||||
|
||||
Reference in new issue
Block a user