destroy

open suspend override fun destroy(path: AbsolutePath, value: T, eventsBus: SchemaEventsBus, removeValue: suspend (value: T) -> Unit)(source)

Destroys and removes value, a value of this schema stored by the form manager, sending events about the destruction through eventsBus. The provided path represents the path of the value being destroyed within the form manager. removeValue should always be called to remove the value.

Destruction events should be emitted "top down": this means that an event signaling the destruction of a parent value must be emitted before all events signaling the destruction of its children. As a side effect of this, implementations of destroy must not bail when their coroutine context is no longer active, since the early signaling of the parent value being destroyed means that all children must also have their destruction signaled.

Because the value is being removed from the form manager, emitted events can (and should) reference parts of value.