Yes you can use the state { ... } syntax to modify states in the state of a protocol instance.
In more details, the state function takes a function as parameter that transforms the state of the instance to the next state of that instance.
Note: it has nothing to do with the list of available states in the protocol declaration. See below for details.
So valid syntaxes are
state { "myNewState" }
state { it }
state { it -> myFunction(it) }
state { myFunction(it) }
state { oldState ->
if (oldState == "old") {
"new"
} else {
oldState
}
}
Or more complicated logic. This function can be applied to none, some or all of the protocol instances of a type, meaning the condition can be either surrounding or included in the state function.
Hope this helps
State machine migration
The list of available states in a protocol declaration can be updated in a migration with the following syntax