Rename `Nothing` type to avoid confusion with Kotlin's
Kotlin has standard type which is named Nothing. It is used in function declarations when it never returns because of throwing an exception.
We have a specialized Message type, io.spine.server.model.Nothing, which serves as a return type of handler methods that do not return anything. These methods do return an instance of such message and exit normally.
This may bring various confusions for Kotlin people:
-
Why do we have a handler method that never completes? Just by looking at the method signature, it's not possible to tell that it's Spine-specific
Nothing, not the standard Kotlin's one. -
What doesn't this handler work? I don't know what declaring wrong
Nothingin a Kotlin code for a handler would cause, but I'm not sure it would be OK. - Fully-qualified Spine's
Nothingwhen the user's code needs to use Kotlin's one. - etc.
In order to avoid this confusion we need to have a type with another name.
To be mentioned as breaking change in Release Notes.
Suggested alternative name: None.
Previously suggested empty Tuple type won't work because our Nothing is frequently used in tules like this: EitherOf2<JobComplete, Nothing>.
We currently have two typealias-es called NothingHappened and NoReaction. This should ease the name clash with the standard Kotlin type.
See the io.spine.server.model.EventExts.kt file for details.
@alexander-yevsyukov
We can only return Nothing in reaction to some event, which we may or may not want to react upon.
It is impossible to return Nothing from a command handler for obvious reasons.
NoReaction reflects what we want to say perfectly:
"Something has happened, and we could potentially react on it. But at this time, we chose not to."
Using NothingHappened is misleading, because it sounds like an event. But as stated earlier, some event has happened—we just don't want to react.
Therefore, I'd stick to NoReaction as a typealias. And I would drop NothingHappened.
Therefore, I'd stick to
NoReactionas atypealias. And I would dropNothingHappened.
Yeah, see this commit.
Resolved by #1554.