stephanenicolas / robospice

Repo of the Open Source Android library : RoboSpice. RoboSpice is a modular android library that makes writing asynchronous long running tasks easy. It is specialized in network requests, supports caching and offers REST requests out-of-the box using extension modules.
Apache License 2.0
2.95k stars 545 forks source link

Network requirement should not be done at the service level #409

Open theyann opened 9 years ago

theyann commented 9 years ago

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

softwaremaverick commented 9 years ago

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 notifications@github.com 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 commented 9 years ago

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 Andrew@dync.co.uk 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 notifications@github.com 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.

maciejpigulski commented 9 years ago

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.

theyann commented 9 years ago

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.

softwaremaverick commented 9 years ago

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 notifications@github.com 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.

theyann commented 9 years ago

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

theyann commented 9 years ago

createRequestRunner is currently private though ...

softwaremaverick commented 9 years ago

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 notifications@github.com 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 .

anotherdev commented 9 years ago

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

pop1030123 commented 9 years ago

Has custom request runner not supported yet?

softwaremaverick commented 9 years ago

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" notifications@github.com 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.

nkeskinov commented 9 years ago

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

deinlandel commented 9 years ago

It seems that this library is not maintained anymore..

stephanenicolas commented 9 years ago

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 notifications@github.com:

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 .

softwaremaverick commented 9 years ago

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" notifications@github.com 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 notifications@github.com:

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.

stephanenicolas commented 9 years ago

@softwaremaverick, you've been added. ;)

2015-07-29 11:40 GMT-07:00 softwaremaverick notifications@github.com:

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" notifications@github.com 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 notifications@github.com:

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 .

softwaremaverick commented 9 years ago

Thanks! :-)

On 29 July 2015 22:06:26 BST, "Stéphane Nicolas" notifications@github.com wrote:

@softwaremaverick, you've been added. ;)

2015-07-29 11:40 GMT-07:00 softwaremaverick notifications@github.com:

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" notifications@github.com 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 notifications@github.com:

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.

stephanenicolas commented 9 years ago

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

2015-07-29 14:11 GMT-07:00 softwaremaverick notifications@github.com:

Thanks! :-)

On 29 July 2015 22:06:26 BST, "Stéphane Nicolas" notifications@github.com wrote:

@softwaremaverick, you've been added. ;)

2015-07-29 11:40 GMT-07:00 softwaremaverick notifications@github.com:

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" notifications@github.com 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 notifications@github.com:

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 .