Given that you cannot prevent the user from moving between the plates, a notification of a delay in the calculation will not solve the whole problem. You can tell the user the approximate time until completion, you can display the progress bar, and you can immediately transfer it to the Backup tile to wait for the results, but if it moves away from the tile, you will remain with your original problem.
If the user decided to leave after all this information, she must have made a conscious decision to interrupt the proceedings. It would be bad for UX to transport it back to the Revision Order. Now what?
You reasonably reasonably assume that the callback function sent using calculateOrder should pass the intendedStartingPoint parameter to setLocation . You are worried that this will require you to change each call to setLocation to accommodate a new parameter. Never fear, JavaScript offers a neat way to solve this dilemma.
You can add a new parameter to setLocation without changing existing calls. It just requires that intendedStartingPoint be the last argument in the setLocation argument setLocation . Then your new version of setLocation can check the intendedStartingPoint value to see if it is undefined .
If intendedStartingPoint is undefined , you know that setLocation receives one of the old calls, those that do not go through intendedStartingPoint . In these cases, you ignore the intendedStartingPoint and act as before. Otherwise, you compare the intendedStartingPoint with your current location and continue according to the result of the comparison.
Even better, use the new intendedStartingPoint parameter, but an object named options that contains intendedStartingPoint as one of its attributes. This allows you to pass additional optional values ββto setLocation , if necessary in the future.
The new setLocation behavior setLocation pretty simple. Before setting a new location, you check to see if the intendedStartingPoint matches your current location. If so, you do not need to do anything, because the user is already where she intended to be. But if the intendedStartingPoint is different from the current location, the user has moved, so you are doing something like this:
if (LocationManager.currentLocation !== options.intendedStartingPoint) {