This pattern seems to come up frequently enough. Wanting to either retrieve or create a field.
The big question is, is it safe to do this? Seems as safe as any other approach, if not moreso.
The idea is to synchronously submit ops to create the value if it's not there, and always return it. Nullable fields are typed as non-null with this getter. A valid init must be supplied as second param, if the item can't be fully defaulted.
This pattern seems to come up frequently enough. Wanting to either retrieve or create a field.
The big question is, is it safe to do this? Seems as safe as any other approach, if not moreso.
The idea is to synchronously submit ops to create the value if it's not there, and always return it. Nullable fields are typed as non-null with this getter. A valid init must be supplied as second param, if the item can't be fully defaulted.