Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not await wasm connector #711

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/svelte-example/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { loadCSV } from "@uwdata/mosaic-sql";

async function init() {
const wasm = await wasmConnector();
const wasm = wasmConnector();
coordinator().databaseConnector(wasm);

await coordinator().exec(
Expand Down
102 changes: 49 additions & 53 deletions examples/vega-example/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,54 @@ import * as vg from '@uwdata/vgplot';
import embed from 'vega-embed';
import { FilteredVegaClient, SelectionVegaClient, spec } from './vega.js';

async function init() {
const vegaPlot = document.createElement('div');
const result = await embed(vegaPlot, spec, { actions: false });

const wasm = await wasmConnector({ log: false });
coordinator().databaseConnector(wasm);

await coordinator().exec(
loadCSV("weather", `${window.location}seattle-weather.csv`)
);

const selection = Selection.intersect();

const client1 = new SelectionVegaClient({
view: result.view,
table: "weather",
dataset: "table",
selection: selection,
});
coordinator().connect(client1);

const client2 = new FilteredVegaClient({
view: result.view,
table: "weather",
dataset: "filteredTable",
filter: selection,
});
coordinator().connect(client2);

document.querySelector("#plots").replaceChildren(
vg.vconcat(
vg.hconcat(
vg.hspace('2em'),
vg.menu({ from: "weather", column: "weather", label: "Weather", as: selection })
),
vg.vspace(4),
vg.hconcat(
vegaPlot,
vg.hspace('1em'),
vg.plot(
vg.dot(
vg.from("weather", { filterBy: selection }),
{ x: "temp_max", y: "wind", fill: "steelblue", fillOpacity: 0.3, r: 2 }
),
vg.intervalX({ as: selection }),
vg.xyDomain(vg.Fixed),
vg.width(350),
vg.height(240)
)
const vegaPlot = document.createElement('div');
const result = await embed(vegaPlot, spec, { actions: false });

const wasm = wasmConnector({ log: false });
coordinator().databaseConnector(wasm);

await coordinator().exec(
loadCSV("weather", `${window.location}seattle-weather.csv`)
);

const selection = Selection.intersect();

const client1 = new SelectionVegaClient({
view: result.view,
table: "weather",
dataset: "table",
selection: selection,
});
coordinator().connect(client1);

const client2 = new FilteredVegaClient({
view: result.view,
table: "weather",
dataset: "filteredTable",
filter: selection,
});
coordinator().connect(client2);

document.querySelector("#plots").replaceChildren(
vg.vconcat(
vg.hconcat(
vg.hspace('2em'),
vg.menu({ from: "weather", column: "weather", label: "Weather", as: selection })
),
vg.vspace(4),
vg.hconcat(
vegaPlot,
vg.hspace('1em'),
vg.plot(
vg.dot(
vg.from("weather", { filterBy: selection }),
{ x: "temp_max", y: "wind", fill: "steelblue", fillOpacity: 0.3, r: 2 }
),
vg.intervalX({ as: selection }),
vg.xyDomain(vg.Fixed),
vg.width(350),
vg.height(240)
)
)
);
}

init();
)
);
6 changes: 6 additions & 0 deletions examples/vega-example/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('vite').UserConfig} */
export default {
build: {
target: 'ES2022',
},
};