android - How to implement transactional request with RoboSpice -


I have a problem handling transaction requests, requesting that the dependence on the results of A's request is B and the request is. I want to keep all A, B and C queues for Spice Service requests. In this way, the task will be easy to keep the ongoing requests in the background easier.

My current implementation request is to collect their response B, C, then from the activity, request A and C received from the data obtained from Request B. But when the activity is stopped, Request A will never be pushed into the request queue. (Request A will be pushed into the request queue that once the activity is returned and see the request status B and C using addListenerIfPending and getDataFromCache )

The other idea is to implement a service which takes responsibility for issuing requests for SpiceServa rather than the activity. But this is a bit complicated.

The ideal solution to the problem can be implemented nested requests, that request requests A, B and C have been implemented in the request queue and hear the data from Request A to request B. But running SpiceRest on a thread managed by SpiceService requires access to something like Spice Manager. I am thinking that there is a problem in using RS in this way.

And another problem is that Request A request is waiting for a complete signal from B and C. Is there a Spiersuite implementation that implements loadDataFromNetwork () in asynchronous approach? / P>

In my opinion, such a situation ("Play B and C in parallel, and then run A") From Robopis's point of view, there should be a peace of work ( SpiceRequest ); I am just making my own Spicruivest implementation which is its loadDataFromNetwork () method Runs multiple network requests in This can cause extra threads inside this method to run B and C requests in parallel.

There is another good library that can help you handle the dependency between asynchronous "work" bolts-Android ().

Here I have used it to run parallel functions in two ways: Wait for them to complete:

  list & lt; Work & lt; Zero & gt; & Gt; Function = new linked list & lt; Task & lt; Zero & gt; & Gt; (); Tasks.add throws exceptions (Task.call (new callable & lt; zero & gt; {@ override public voice call}) {// do task a}}); Tasks.add throws exceptions (Task.call (new callable & lt; null & gt; ()) {@ Override public voice call} {// do task b}})); Task.whenAll (work) .waitForCompletion ();  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -