billmalarky / react-native-queue

A React Native Job Queue
MIT License
795 stars 159 forks source link

Only execute job when network is available #55

Open hannojg opened 5 years ago

hannojg commented 5 years ago

Hey! Do we have a mechanism to only execute jobs once there is network connectivity? Which also means keeping jobs in the queue as long as the network is unavailable.

I wasn't able to find something from a quick look. If not, can you point me where I could start implementing @billmalarky

Thank you so much!

vishgoel007 commented 5 years ago

Hi, did you able to find any solution ?

hannojg commented 5 years ago

No, but I am still interested in an solution!

vishgoel007 commented 5 years ago

I think we can actually implement that in library but sadly author is not responding at all.

rdgomt commented 5 years ago

I've been trying to implement this functionality using @react-native-community/netinfo. I'll let you know if I get this done.

vishgoel007 commented 5 years ago

@rdgomt Is there any solution for this issue too.

vishgoel007 commented 5 years ago

@rdgomt If you haven't implemented that functionality yet, can you guide my how can i do this? I'm thinking about using rxjs for that.

gruffT commented 5 years ago

You can impliment this outside of the library. Add a NetInfo listener and start / stop the queue on network state change. NetInfo.addEventListener(state => { if (state.isInternetReachable) { logger.log('Network connection up, starting queue.'); this.queue.start(); } else { logger.log('Network connection down, stopping queue.'); this.queue.stop(); } });

rdgomt commented 5 years ago

@vishgoel007 I don't know rxjs, but you can use either NetInfo directly or react-native-offline.