- Index
- »
- fan.xeto
- »
- SpecChoice
SpecChoice
@Js
const mixin SpecChoice
Choice APIs for a specific choice spec via Namespace.choice.
Return all choice selections the given instance implements
Return single choice selection considering validation rules
Return if the choice slot allows zero selections
Choice type for the spec
Return if the choice slot allows multiple selections
Spec for this choice - might be slot or choice type
List the choice direct subtypes of given base (defaults to root choice)
abstract Bool isMaybe()
Return if the choice slot allows zero selections
abstract Bool isMultiChoice()
Return if the choice slot allows multiple selections
abstract Spec? selection(Dict instance, Bool checked)
Return single choice selection considering validation rules. This method is a semantically equivalent to:
selections(instance, checked).first
abstract Spec[] selections(Dict instance, Bool checked)
Return all choice selections the given instance implements.
- one selection => return list of one
- zero selections + isMaybe is true => return empty list
- zero selections + isMaybe is false + checked is false => return empty list
- zero selections + isMaybe is false + checked is true => raise exception
- multiple selections + isMultiChoice is false + checked is false => return all
- multiple selections + isMultiChoice is false + checked is true => raise exception
- multiple selections + isMultiChoice is true + checked is true => return all
abstract Spec spec()
Spec for this choice - might be slot or choice type
abstract Spec[] subtypes(Spec base)
List the choice direct subtypes of given base (defaults to root choice). This method can be used to efficiently build choice taxonomy tree.
abstract Spec type()
Choice type for the spec