Default
Provides a constructor function to be used to provide a default value for a property.
Default
A constructor function can be provided that is called to create a default value used for this property.
This constructor will be invoked with new
for each created instance. The default
value is created on demand when the property is read for the first time.
Specify Default
like:
{
prop: {
Default: Array
},
person: {
Default: Person
}
}
Use
const Address = DefineMap.extend( {
street: { type: "string", value: "321 Longbow" },
city: { type: "string", value: "Dallas" }
} );
const Direction = DefineMap.extend( {
from: { Type: Address, Default: Address },
to: { Type: Address, Default: Address }
} );
const direction = new Direction( {
to: { street: "2070 N. Stave" }
} );
direction.from.street; //-> "321 Longbow"
direction.to.street; //-> "2070 N. Stave"