Define state transitions as callbacks.