appsquickly / TyphoonRestClient

Flexible HTTP client for Objective-C and Swift
Apache License 2.0
24 stars 5 forks source link

Data serialization done on main queue #18

Open SandeepAggarwal opened 7 years ago

SandeepAggarwal commented 7 years ago

The Serialization is being done on main queue instead of background queue which is causing the app to become unresponsive in case of large amount of data in request/response. Is there anyway we can offload the serialization to background?

alexgarbarev commented 7 years ago

Hey @SandeepAggarwal. Yes, serialization and validation is done on main queue by default, but you can change it by:

TyphoonRestClient *restClient = [TyphoonRestClient new];

NSOperationQueue *backgroundQueue = [NSOperationQueue new];
//Configure your background queue here

restClient.workQueue = backgroundQueue;
SandeepAggarwal commented 7 years ago

@alexgarbarev Thank you for your reply. Is there any specific reason for not doing it in background by default? Shouldn't it be done in bg always?

alexgarbarev commented 7 years ago

Hey @SandeepAggarwal. The reason of that was serialisation and mapping into database objects such a "Realm" or "CoreData". It requires special treatment, and doing all on main thread avoids crashes.