ios - AFNetworking synchronous calls (like/unlike) -


i need implement like/unlike functionality in app. api calls made afnetworking , success/errors handlers (ios blocks).

problem when user making many clicks on button in short period of time, of request received server in wrong sequence , becomes wrong. example double or double unlike happens.

is there way send request via afnetworking synchronously?

if no best practice design kind of api requests?

disabling button (like comments suggest) not bad idea, if throw spinner or ui change let user know processing change.

otherwise, limit api calls allow single call out. if user presses button, fire call , change boolean or tracking value. if press button again hold unto change state locally wait first callback come in. if keep pressing button keep track of change never fire response until receive notification api call has completed (probably 10-30 second timeout in case fails).

once call completed, see if new value user wants different. if is, send , prevent future changes going out (but track them locally), if same (the user pressed button amount of times while first call out) don't send it.

i delay first call 3 or seconds , every time press button within time period reset timer. way not firing accidental calls unnecessarily (think of coredata save, if know there may few changes make them before saving).

the problem synchronized queue if press button 5 times (or more) have pretty long wait queue. if close application , calls not sent? database has (potentially) inaccurate information.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -