Default value.
Defines a number model property with a default value.
Equivalent to tProp(types.number, defaultValue)
.
Example:
x: tProp(42) // an optional number that will take the value `42` when undefined.
Default value.
Defines a boolean model property with a default value.
Equivalent to tProp(types.boolean, defaultValue)
.
Example:
x: tProp(true) // an optional boolean that will take the value `true` when undefined.
Default value.
Defines a model property, with an optional function to generate a default value
if the input snapshot / model creation data is null
or undefined
and with an associated type checker.
Example:
x: tProp(types.number, () => 10) // an optional number, with a default value of 10
x: tProp(types.array(types.number), () => []) // an optional number array, with a default empty array
Type checker.
Default value generator function.
Defines a model property, with an optional default value
if the input snapshot / model creation data is null
or undefined
and with an associated type checker.
You should only use this with primitive values and never with object values
(array, model, object, etc).
Example:
x: tProp(types.number, 10) // an optional number, with a default value of 10
Type checker.
Default value generator function.
Defines a model property with no default value and an associated type checker.
Example:
x: tProp(types.number) // a required number
x: tProp(types.maybe(types.number)) // an optional number, which defaults to undefined
Type checker.
Defines a string model property with a default value. Equivalent to
tProp(types.string, defaultValue)
.Example: