Optional
then: Primitive<Target>The property type to read if no other condition is met.
Optional
args: RelationParameters<This, Args>Optional arguments passed to the nested type definition if the 'cond' pass.
The property decorator function.
In the following example the data
property of the Protocol
class will
be associated with a unsigned 8-bits integer if the type
property doesn't
equals to 0x01
.
class Protocol {
@Relation(PrimitiveSymbol.u8)
type: number
@IfThen(_ => _.type === 0x01, PrimitiveSymbol.u16)
@Else(PrimitiveSymbol.u8)
data: number
}
@Else
decorator acts as a fallback when no other condition is met. This decorator always executes if none of the preceding conditions passed.