Skip to content

Commit b140a33

Browse files
authored
Remove workaround for mosaic client updates (#89)
The manual listener for `filterBy` changes is no longer needed with the latest mosaic. The coordinator now properly handles `Selection` updates and triggers query/queryResult calls when filterBy is updated.
1 parent 247070f commit b140a33

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

lib/clients/ValueCounts.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
column,
99
count,
1010
type ExprNode,
11-
type MaybeArray,
1211
Query,
1312
sql,
1413
sum,
@@ -18,7 +17,6 @@ import { effect } from "@preact/signals-core";
1817

1918
import { ValueCountsPlot } from "../utils/ValueCountsPlot.ts";
2019
import { assert } from "../utils/assert.ts";
21-
import { isFlechetteTable } from "../utils/guards.ts";
2220

2321
interface UniqueValuesOptions {
2422
/** The table to query. */
@@ -43,28 +41,6 @@ export class ValueCounts extends MosaicClient {
4341
this.#table = options.table;
4442
this.#column = options.field.name;
4543
this.#field = options.field;
46-
47-
// FIXME: There is some issue with the mosaic client or the query we
48-
// are using here. Updates to the Selection (`filterBy`) seem to be
49-
// missed by the coordinator, and query/queryResult are not called
50-
// by the coordinator when the filterBy is updated.
51-
//
52-
// Here we manually listen for the changes to filterBy and update this
53-
// client internally. It _should_ go through the coordinator.
54-
options.filterBy.addEventListener("value", async () => {
55-
if (!this.#plot || !this.coordinator) {
56-
return;
57-
}
58-
let filters = options.filterBy.predicate(this);
59-
assert(
60-
isExprNodeArray(filters),
61-
`Filter is not expression array: ${filters}`,
62-
);
63-
let query = this.query(filters);
64-
let data = await this.coordinator.query(query);
65-
assert(isFlechetteTable(data), "Expected a flechette table.");
66-
this.#plot.data.value = data;
67-
});
6844
}
6945

7046
override query(filter: Array<ExprNode> = []): Query {
@@ -130,9 +106,3 @@ export class ValueCounts extends MosaicClient {
130106
};
131107
}
132108
}
133-
134-
function isExprNodeArray(
135-
x: MaybeArray<string | boolean | undefined | ExprNode>,
136-
): x is Array<ExprNode> {
137-
return Array.isArray(x) && x.every((y) => typeof y === "object");
138-
}

0 commit comments

Comments
 (0)