Adds an observer to the state machine.
The observer to add
Adds an observer using a lambda.
The observer function