robospice icon indicating copy to clipboard operation
robospice copied to clipboard

Network requirement should not be done at the service level

Open theyann opened this issue 10 years ago • 18 comments

Hello,

Here is my issue: we have just robospiced our whole app. However we do have some requests that must run in the background but that do not particularly require the network. The issue is that if we have no connectivity, those "don't require network" get a NoNetworkException.

Our current, short term, solution (which I don't like) is that we have 2 spice managers bound to 2 different services, and we execute the request on the proper one based on the request's requirements.

Is there a better solution than this ? Could we maybe have a "doInBackground" method in the request on top of the "loadDataFromNetwork" one ? Anyone has a better solution ?

Thanks a bunch in advance.

Yannick

theyann avatar Feb 27 '15 07:02 theyann

I believe there's been a recent change to make setRequestRunner to be a protected method. As such you may be able to add a custom request runner which for network requests you call the default request runner bit for non network you can do something else

On 27 February 2015 07:42:17 GMT+00:00, Yannick Lemin [email protected] wrote:

Hello,

Here is my issue: we have just robospiced our whole app. However we do have some requests that must run in the background but that do not particularly require the network. The issue is that if we have no connectivity, those "don't require network" get a NoNetworkException.

Our current, short term, solution (which I don't like) is that we have 2 spice managers bound to 2 different services, and we execute the request on the proper one based on the request's requirements.

Is there a better solution than this ? Could we maybe have a "doInBackground" method in the request on top of the "loadDataFromNetwork" one ? Anyone has a better solution ?

Thanks a bunch in advance.

Yannick


Reply to this email directly or view it on GitHub: https://github.com/stephanenicolas/robospice/issues/409

Sent from my Android device with K-9 Mail. Please excuse my brevity.

softwaremaverick avatar Feb 27 '15 08:02 softwaremaverick

In fact maybe request runner could do with refactoring into a Base class which would allow the network checkers to be done only in the default request runner from within a generic check pre conditions method

On 27 February 2015 08:24:41 GMT+00:00, Andrew Clark [email protected] wrote:

I believe there's been a recent change to make setRequestRunner to be a protected method. As such you may be able to add a custom request runner which for network requests you call the default request runner bit for non network you can do something else

On 27 February 2015 07:42:17 GMT+00:00, Yannick Lemin [email protected] wrote:

Hello,

Here is my issue: we have just robospiced our whole app. However we do have some requests that must run in the background but that do not particularly require the network. The issue is that if we have no connectivity, those "don't require network" get a NoNetworkException.

Our current, short term, solution (which I don't like) is that we have 2 spice managers bound to 2 different services, and we execute the request on the proper one based on the request's requirements.

Is there a better solution than this ? Could we maybe have a "doInBackground" method in the request on top of the "loadDataFromNetwork" one ? Anyone has a better solution ?

Thanks a bunch in advance.

Yannick


Reply to this email directly or view it on GitHub: https://github.com/stephanenicolas/robospice/issues/409

Sent from my Android device with K-9 Mail. Please excuse my brevity.

Sent from my Android device with K-9 Mail. Please excuse my brevity.

softwaremaverick avatar Feb 27 '15 08:02 softwaremaverick

As a followup to what @softwaremaverick said, you can override

protected RequestProcessor createRequestProcessor(CacheManager cacheManager, RequestProgressManager requestProgressManager, RequestRunner requestRunner)

method in your SpiceService and pass in your own implementation of RequestRunner that will do some custom networking.

I am not sure about any set API as I have been doing such overrides via class extension.

maciejpigulski avatar Feb 27 '15 08:02 maciejpigulski

But that's still at the service level, I would need something like that but at request level ... Or maybe have some accessor to the service from the spice manager to be able to change something in there but it's a bad idea in my opinion.

theyann avatar Feb 27 '15 08:02 theyann

But all you need to do is modify a request runner to say if the request instanceof nonetwirkrequest then do non network request runner call.

Or you modify the request runner to let the request handle network checking.

Either way a service is responsible for handling your request therefore it needs to do something different now but not something that should be forced on all unnecessarily.

On 27 February 2015 08:58:21 GMT+00:00, Yannick Lemin [email protected] wrote:

But that's still at the service level, I would need something like that but at request level ... Or maybe have some accessor to the service from the spice manager to be able to change something in there but it's a bad idea in my opinion.


Reply to this email directly or view it on GitHub: https://github.com/stephanenicolas/robospice/issues/409#issuecomment-76358521

Sent from my Android device with K-9 Mail. Please excuse my brevity.

softwaremaverick avatar Feb 27 '15 09:02 softwaremaverick

Ok I'll check that request runner, I've never actually looked at that. Thanks

theyann avatar Feb 27 '15 09:02 theyann

createRequestRunner is currently private though ...

theyann avatar Feb 27 '15 09:02 theyann

There's a pending pull request https://github.com/stephanenicolas/robospice/pull/407 which makes it protected.

However, you could go for the previously suggested approach of overriding createRequestProcessor with a new request runner.

On 27 February 2015 at 09:15 Yannick Lemin [email protected] wrote:

createRequestRunner is currently private though ...

— Reply to this email directly or view it on GitHub https://github.com/stephanenicolas/robospice/issues/409#issuecomment-76360504 .

softwaremaverick avatar Feb 27 '15 13:02 softwaremaverick

Is it possible to have SpiceService to consult NetworkStateChecker for each request? http://stackoverflow.com/a/21694141/802421

anotherdev avatar Apr 27 '15 11:04 anotherdev

Has custom request runner not supported yet?

pop1030123 avatar Jul 14 '15 14:07 pop1030123

It's pending a merge request I believe. I'm more then willing to manage pull requests to get some quick fixes in. But I need the permissions.

On 14 July 2015 15:45:53 BST, "pop.fu" [email protected] wrote:

Has custom request runner not supported yet?


Reply to this email directly or view it on GitHub: https://github.com/stephanenicolas/robospice/issues/409#issuecomment-121259462

Sent from my Android device with K-9 Mail. Please excuse my brevity.

softwaremaverick avatar Jul 14 '15 17:07 softwaremaverick

It seems that you need @stephanenicolas to add you to maintainers.

nkeskinov avatar Jul 14 '15 17:07 nkeskinov

It seems that this library is not maintained anymore..

deinlandel avatar Jul 27 '15 05:07 deinlandel

Sorry guys,

it's not that the lib is not maintained is that it is quite complete and honnestly, yes time has been missing.

Who wants to be added to the RS maintainers ?

S.

2015-07-26 22:21 GMT-07:00 Lev Shock [email protected]:

It seems that this library is not maintained anymore..

— Reply to this email directly or view it on GitHub https://github.com/stephanenicolas/robospice/issues/409#issuecomment-125089281 .

stephanenicolas avatar Jul 29 '15 17:07 stephanenicolas

Yes please. I also agree that it is quite complete and only minor enhancements would be required for further flexibility.

On 29 July 2015 18:46:51 BST, "Stéphane Nicolas" [email protected] wrote:

Sorry guys,

it's not that the lib is not maintained is that it is quite complete and honnestly, yes time has been missing.

Who wants to be added to the RS maintainers ?

S.

2015-07-26 22:21 GMT-07:00 Lev Shock [email protected]:

It seems that this library is not maintained anymore..

— Reply to this email directly or view it on GitHub

https://github.com/stephanenicolas/robospice/issues/409#issuecomment-125089281 .


Reply to this email directly or view it on GitHub: https://github.com/stephanenicolas/robospice/issues/409#issuecomment-126032811

Sent from my Android device with K-9 Mail. Please excuse my brevity.

softwaremaverick avatar Jul 29 '15 18:07 softwaremaverick

@softwaremaverick, you've been added. ;)

2015-07-29 11:40 GMT-07:00 softwaremaverick [email protected]:

Yes please. I also agree that it is quite complete and only minor enhancements would be required for further flexibility.

On 29 July 2015 18:46:51 BST, "Stéphane Nicolas" [email protected] wrote:

Sorry guys,

it's not that the lib is not maintained is that it is quite complete and honnestly, yes time has been missing.

Who wants to be added to the RS maintainers ?

S.

2015-07-26 22:21 GMT-07:00 Lev Shock [email protected]:

It seems that this library is not maintained anymore..

— Reply to this email directly or view it on GitHub

< https://github.com/stephanenicolas/robospice/issues/409#issuecomment-125089281

.


Reply to this email directly or view it on GitHub:

https://github.com/stephanenicolas/robospice/issues/409#issuecomment-126032811

Sent from my Android device with K-9 Mail. Please excuse my brevity.

— Reply to this email directly or view it on GitHub https://github.com/stephanenicolas/robospice/issues/409#issuecomment-126054044 .

stephanenicolas avatar Jul 29 '15 21:07 stephanenicolas

Thanks! :-)

On 29 July 2015 22:06:26 BST, "Stéphane Nicolas" [email protected] wrote:

@softwaremaverick, you've been added. ;)

2015-07-29 11:40 GMT-07:00 softwaremaverick [email protected]:

Yes please. I also agree that it is quite complete and only minor enhancements would be required for further flexibility.

On 29 July 2015 18:46:51 BST, "Stéphane Nicolas" [email protected] wrote:

Sorry guys,

it's not that the lib is not maintained is that it is quite complete and honnestly, yes time has been missing.

Who wants to be added to the RS maintainers ?

S.

2015-07-26 22:21 GMT-07:00 Lev Shock [email protected]:

It seems that this library is not maintained anymore..

— Reply to this email directly or view it on GitHub

<

https://github.com/stephanenicolas/robospice/issues/409#issuecomment-125089281

.


Reply to this email directly or view it on GitHub:

https://github.com/stephanenicolas/robospice/issues/409#issuecomment-126032811

Sent from my Android device with K-9 Mail. Please excuse my brevity.

— Reply to this email directly or view it on GitHub

https://github.com/stephanenicolas/robospice/issues/409#issuecomment-126054044 .


Reply to this email directly or view it on GitHub: https://github.com/stephanenicolas/robospice/issues/409#issuecomment-126095664

Sent from my Android device with K-9 Mail. Please excuse my brevity.

softwaremaverick avatar Jul 29 '15 21:07 softwaremaverick

Thx to you, you have been a long time contributor already

2015-07-29 14:11 GMT-07:00 softwaremaverick [email protected]:

Thanks! :-)

On 29 July 2015 22:06:26 BST, "Stéphane Nicolas" [email protected] wrote:

@softwaremaverick, you've been added. ;)

2015-07-29 11:40 GMT-07:00 softwaremaverick [email protected]:

Yes please. I also agree that it is quite complete and only minor enhancements would be required for further flexibility.

On 29 July 2015 18:46:51 BST, "Stéphane Nicolas" [email protected] wrote:

Sorry guys,

it's not that the lib is not maintained is that it is quite complete and honnestly, yes time has been missing.

Who wants to be added to the RS maintainers ?

S.

2015-07-26 22:21 GMT-07:00 Lev Shock [email protected]:

It seems that this library is not maintained anymore..

— Reply to this email directly or view it on GitHub

<

https://github.com/stephanenicolas/robospice/issues/409#issuecomment-125089281

.


Reply to this email directly or view it on GitHub:

https://github.com/stephanenicolas/robospice/issues/409#issuecomment-126032811

Sent from my Android device with K-9 Mail. Please excuse my brevity.

— Reply to this email directly or view it on GitHub

< https://github.com/stephanenicolas/robospice/issues/409#issuecomment-126054044

.


Reply to this email directly or view it on GitHub:

https://github.com/stephanenicolas/robospice/issues/409#issuecomment-126095664

Sent from my Android device with K-9 Mail. Please excuse my brevity.

— Reply to this email directly or view it on GitHub https://github.com/stephanenicolas/robospice/issues/409#issuecomment-126096728 .

stephanenicolas avatar Jul 29 '15 21:07 stephanenicolas