Constructor.
Can be used to indicate that the state has been changed externally (e.g. to some "invalid"/"dirty" state). If a transition operation is already in progress, assume that it will change the state to the given state instead of its actual goal.
Set the goal state. Starts off a transition operation if needed. Returns a promise that will be fulfilled when we reach the goal state, or rejected if the goal state changes before it is reached.
The current state transition.
The promise that will be fulfilled when we reach the goal state.
The final state that we want to be in.
The state that any current change is moving towards.
The state that any current change is moving away from.
The asynchronous implementation function which actually changes the state.
Let f(x) be an expensive operation which changes something to (or towards) state x. At most one f call may be in progress at any time. This type orchestrates a series of operations that eventually bring the state to some goal, while allowing the goal to change at any time.