@@ -7,16 +7,14 @@ import DeckGL from "@deck.gl/react/typed";
7
7
import { MapViewState , type Layer } from "@deck.gl/core/typed" ;
8
8
import { BaseLayerModel , initializeLayer } from "./model/index.js" ;
9
9
import type { WidgetModel } from "@jupyter-widgets/base" ;
10
- import { initParquetWasm } from "./parquet.js" ;
10
+ import { useParquetWasm } from "./parquet.js" ;
11
11
import { getTooltip } from "./tooltip/index.js" ;
12
12
import { isDefined , loadChildModels } from "./util.js" ;
13
13
import { v4 as uuidv4 } from "uuid" ;
14
14
import { Message } from "./types.js" ;
15
15
import { flyTo } from "./actions/fly-to.js" ;
16
16
import { useViewStateDebounced } from "./state" ;
17
17
18
- await initParquetWasm ( ) ;
19
-
20
18
const DEFAULT_INITIAL_VIEW_STATE = {
21
19
latitude : 10 ,
22
20
longitude : 0 ,
@@ -65,6 +63,10 @@ async function getChildModelState(
65
63
function App ( ) {
66
64
let model = useModel ( ) ;
67
65
66
+ let [ parquetWasmBinary ] = useModelState < DataView | null > (
67
+ "_parquet_wasm_content" ,
68
+ ) ;
69
+ let [ parquetWasmReady ] = useParquetWasm ( parquetWasmBinary ) ;
68
70
let [ mapStyle ] = useModelState < string > ( "basemap_style" ) ;
69
71
let [ mapHeight ] = useModelState < number > ( "_height" ) ;
70
72
let [ showTooltip ] = useModelState < boolean > ( "show_tooltip" ) ;
@@ -108,7 +110,15 @@ function App() {
108
110
let [ stateCounter , setStateCounter ] = useState < Date > ( new Date ( ) ) ;
109
111
110
112
useEffect ( ( ) => {
113
+ if ( ! parquetWasmReady ) {
114
+ return ;
115
+ }
116
+
111
117
const callback = async ( ) => {
118
+ if ( ! parquetWasmReady ) {
119
+ throw new Error ( "inside callback but parquetWasm not ready!" ) ;
120
+ }
121
+
112
122
const childModels = await loadChildModels (
113
123
model . widget_manager ,
114
124
childLayerIds ,
@@ -122,7 +132,7 @@ function App() {
122
132
setSubModelState ( newSubModelState ) ;
123
133
} ;
124
134
callback ( ) . catch ( console . error ) ;
125
- } , [ childLayerIds ] ) ;
135
+ } , [ parquetWasmReady , childLayerIds ] ) ;
126
136
127
137
const layers : Layer [ ] = [ ] ;
128
138
for ( const subModel of Object . values ( subModelState ) ) {
0 commit comments