Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
// Exit the current State if ( currentState && currentState.exiting ) sendNotification( currentState.exiting, data, nextState.name ); // Check to see whether the transition has been canceled if ( canceled ) { canceled = false; return; } // Enter the next State if ( nextState.entering ) sendNotification( nextState.entering, data ); currentState = nextState; // Send the notification configured to be sent when this specific state becomes current if ( nextState.changed ) sendNotification( currentState.changed, data ); // Notify the app generally that the state changed and what the new state is sendNotification( CHANGED, currentState, currentState.name );