-
Notifications
You must be signed in to change notification settings - Fork 11
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
Engine API: expand and improve select write semantics (also anticipating future types) #97
Comments
Sounds similar to https://github.com/getodk/javarosa/blob/3f579c43f81049475e032948ba16f388e19620fd/src/main/java/org/javarosa/core/model/data/IAnswerData.java#L128 ? There's also a |
Yep that's pretty much exactly what got me thinking of a common, non-node-type-specific API.
Right. I don't know if the hypothetical polymorophic FWIW, there's already a interface SelectItem {
label: TextRange;
value: string;
} As a interface ValueContext {
// ...
encodeValue(runtimeValue: SelectItem[]): string;
decodeValue(instanceValue: string): SelectItem[];
} It's reasonable to consider expanding that interface (or having another one like it but for more ambiguous/polymorphic input types) to support a case like I do think the current And possibly a good first step would be to loosen the
It also seems pretty likely, given other things I've learned working on #25, that interface SelectItem<T = string> {
label: TextRange;
value: T;
} ... with that cascading out to
|
While the current
SelectNode.select
andSelectNode.deselect
methods are sufficient, their ergonomics leave something to be desired for a variety of use cases that are now becoming reality (making them easier to discuss than when the interface was initially designed).SelectItem
s (allowing clients to toggle their selected state without redundantly checking their selected-ness, simplifying a per-checkbox toggle action). A proposed name oftoggle
was introduced. We may also consider prior art in APIs with toggle semantics, some of which include a "force" option (although we should consider it carefully, as that particular example tends to confuse).SelectItem
s at once. While a proposed name ofsetValue
was suggested, I'd caution that it may be wise to reserve that name for other use cases (see next point).SelectItem
object interface introduced in Refactor: engine <-> client interface implementation #67), as well as a much broader concern around theScenario
client's utilization of a highly polymorphic value assignment interface. That porting effort will include copious notes, including many on the topic of casting of value types. While I have some concerns about making the engine's APIs overly flexible, in general I think it would be a good idea for select-specific APIs to be mindful of the possibility that a sharedsetValue
interface (across all value-bearing node types) might come to be.The text was updated successfully, but these errors were encountered: