ObjectHooks.onSetMissingField
onSetMissingField($fieldName) -> none
Description
Add this method to your class to handle assignment to fields that are not publicly defined.
Return Result.ok(true)
if the assignment was successful. Otherwise, return Result.fail()
, to trigger an error.
class Timer { fields { durationSecs: 0 } fn zDynamicSet($fieldName, $value) { if $fieldName == 'durationMins' { // convert minutes to seconds @.state.durationSecs = $value * 60 return Result.ok(true) } return Result.fail() } } $timer = Timer() $timer.durationMins = 10