If we have the following protocol definition.
class Chunk {
constructor(type, size) {
this._type = type
this._size = size
}
}
class Protocol {
@Relation(PrimitiveSymbol.u8)
type: number
@Relation(PrimitiveSymbol.u8)
size: number
@Relation(Chunk, (targetInstance: Protocol) => [targetInstance.type, targetInstance.size])
data: Chunk
}
The RelationParameters
definition to pass the property type
and size
to the Chunk
constructor is the following (targetInstance: Protocol) => [targetInstance.type, targetInstance.size]
RelationParameters function definition receive the target instance and return an array of parameter to pass to the relation.