- Index
- »
- fan.xeto
- »
- SpecChoice
SpecChoice
@Js
const mixin SpecChoice
Choice APIs for a specific choice spec via Namespace.choice.
Return if the choice slot allows zero selections
Return if the choice slot allows multiple selections
Return single choice selection considering validation rules
Return all choice selections the given instance implements
Spec for this choice - might be slot or choice type
List the choice direct subtypes of given base (defaults to root choice)
Choice type for the spec
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 := true)
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 := true)
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 := this.spec())
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