This repository is meant to solve Race condition for side effects in CoRedux Side Effects
As of this commit, the race condition has been resolved by implementing SideEffect rather than instantiating SimpleSideEffect.
Only use SimpleSideEffect and CancellableSideEffect when you want to cancel the side effect if a new action of the same type comes in too quickly.
To see the original problem, go back to commit a7f7b155 ("Simplified test"). To see other solutions attempted, look at other branches such as feature/solve-by-using-multiple-actions.
You can demonstrate the solution manually or automatically using the automated test in the repository.
- Launch app in emulator
- Leave "Add Delay" unchecked
- Click "Do Async Task"
- The output should read "[init, go, go, done, done]"
The original problem could be worked around by introducing a delay between the two events which resulted in the following behavior:
- Launch app in emulator
- Check "Add Delay"
- Click "Do Async Task"
- The output should read "[init, go, done, go, done]"
The two test cases above are automated as Espresso tests. To observe their behavior, run as follows:
- Open MainActivityTest in Android Studio
- Click the green run button in the gutter to run the two tests
shouldDoTwoAsyncTasksWithoutDelay
passesshouldDoTwoAsyncTasksWithDelay
passes