@@ -7,16 +7,14 @@ import DeckGL from "@deck.gl/react/typed";
77import { MapViewState , type Layer } from "@deck.gl/core/typed" ;
88import { BaseLayerModel , initializeLayer } from "./model/index.js" ;
99import type { WidgetModel } from "@jupyter-widgets/base" ;
10- import { initParquetWasm } from "./parquet.js" ;
10+ import { useParquetWasm } from "./parquet.js" ;
1111import { getTooltip } from "./tooltip/index.js" ;
1212import { isDefined , loadChildModels } from "./util.js" ;
1313import { v4 as uuidv4 } from "uuid" ;
1414import { Message } from "./types.js" ;
1515import { flyTo } from "./actions/fly-to.js" ;
1616import { useViewStateDebounced } from "./state" ;
1717
18- await initParquetWasm ( ) ;
19-
2018const DEFAULT_INITIAL_VIEW_STATE = {
2119 latitude : 10 ,
2220 longitude : 0 ,
@@ -65,6 +63,10 @@ async function getChildModelState(
6563function App ( ) {
6664 let model = useModel ( ) ;
6765
66+ let [ parquetWasmBinary ] = useModelState < DataView | null > (
67+ "_parquet_wasm_content" ,
68+ ) ;
69+ let [ parquetWasmReady ] = useParquetWasm ( parquetWasmBinary ) ;
6870 let [ mapStyle ] = useModelState < string > ( "basemap_style" ) ;
6971 let [ mapHeight ] = useModelState < number > ( "_height" ) ;
7072 let [ showTooltip ] = useModelState < boolean > ( "show_tooltip" ) ;
@@ -108,7 +110,15 @@ function App() {
108110 let [ stateCounter , setStateCounter ] = useState < Date > ( new Date ( ) ) ;
109111
110112 useEffect ( ( ) => {
113+ if ( ! parquetWasmReady ) {
114+ return ;
115+ }
116+
111117 const callback = async ( ) => {
118+ if ( ! parquetWasmReady ) {
119+ throw new Error ( "inside callback but parquetWasm not ready!" ) ;
120+ }
121+
112122 const childModels = await loadChildModels (
113123 model . widget_manager ,
114124 childLayerIds ,
@@ -122,7 +132,7 @@ function App() {
122132 setSubModelState ( newSubModelState ) ;
123133 } ;
124134 callback ( ) . catch ( console . error ) ;
125- } , [ childLayerIds ] ) ;
135+ } , [ parquetWasmReady , childLayerIds ] ) ;
126136
127137 const layers : Layer [ ] = [ ] ;
128138 for ( const subModel of Object . values ( subModelState ) ) {
0 commit comments