I’ve recently had the problem of trying to display a progress dialog when executing an asynchronous operation and to dismiss that progress dialog when the operation completes.
I wanted to build a way to do this that is generic to my application, so that it would work with any asynchronous operation in order to reduce duplication of writing progress dialog logic everywhere in the code.
Looking at the problem
So here is some basic pseudo-code of the problem.
Now the problem with this code is that it would have to be repeated everywhere I want to make an asynchronous call and display a progress dialog.
If I want to do this in my application every time that I make an asynchronous call, I have to put this kind of code in many places in the application.
You can also see a mixing of responsibilities here. We are handling UI related…
Ver la entrada original 574 palabras más