AndroidNetworkManager icon indicating copy to clipboard operation
AndroidNetworkManager copied to clipboard

Automatic lifecycle management

Open chweez opened this issue 8 years ago • 8 comments

For now, the user must call Tovuti.from(context).stop() but i want to make it automatic when the Activity/Fragment stops. So, the way Glide implements this feature is by having a view-less Fragment. The view-less fragment is attached to the activity/fragment where the Monitor is attached and these Fragment receives the lifecycle events of the parent/host thus allowing the Monitor to respond accordingly without user intervention (i.e. calling stop method). I'll try see if this way will suit us. The only problem is increasing the complexity of the library unnecessarily. What do you think @jumadeveloper?

chweez avatar Aug 30 '17 11:08 chweez

Yes, having it kill or stop itself is a great idea, ping me if you need any help, but I can see you are doing great already!

jumaallan avatar Aug 30 '17 18:08 jumaallan

Haha...thanks. Though I'll create another pull for the documentation...

chweez avatar Aug 30 '17 18:08 chweez

Great

jumaallan avatar Aug 31 '17 10:08 jumaallan

I've been considering this... @jumadeveloper help me with this... I'd like to hear your take on the matter. Any other perspective.

chweez avatar Sep 12 '17 22:09 chweez

@chweez I think we should make it handle the lifecycle automatically, by somehow receiving the lifecycle event of the parent, as you had stated earlier when creating the issue to reduce code setup needed by the user

jumaallan avatar Sep 13 '17 08:09 jumaallan

@chweez I have an idea, we can use livedata own lifecylcle manager, to manage our lifecylce here easily. Have a look at it and probably get back with ideas or suggestions

jumaallan avatar Sep 17 '17 10:09 jumaallan

I've been looking at this. I have a concern for including the LiveData and LifecycleOwner from arch components because of the external dependencies. However, it may prove worth it. What I'm thinking is another module that depends on livedata and another that depends on rxjava. Adding the module dependency will pull in the transitive dependency to :networkmanager. The module names will be; :networkmanager-livedata and :networkmanager-rxjava

chweez avatar Oct 10 '17 09:10 chweez

@chweez I completely agree with you

jumaallan avatar Oct 10 '17 16:10 jumaallan