DSpotDevelopers / declex

DecleX - Declarative Framework for Android, easier and faster coding.
Other
168 stars 25 forks source link

Create a method to reload a request in case of failure #125

Open yasmanmesa opened 7 years ago

yasmanmesa commented 7 years ago

It would be great to have a method that does a reload in case the action fails with the model. Following the line of... https://github.com/smaugho/declex/issues/86, could be realized with the reload the same defined actions. For example:

$PutModel(login).onFailed().toast("An error occurred")
                .always().dismiss(progressDialog).reload();

This would execute the $PutModel(login) again and, in case of failure, would display the message. Maybe it would be good to specify the amount of reloads or just do it once more.

smaugho commented 7 years ago

It is good, but it should be placed in onFaled not in always:

$PutModel(login).onFailed().toast("An error occurred").retry()
                .always().dismiss(progressDialog);

I also prefer retry, since it can be applied to more actions, and not exactly an action that is "loading" information.