ViewModel assembly

ViewModel

 

1. The data persistence,

Reconstruction conventionally used to destroy activity onSaveInstanceState, but only for a small amount of data may be serialized (not available storage space)

 

Because of the life cycle is ViewModel Activity throughout the life cycle, including the activity caused by the rotation of re-creating activity, until the true sense of the destruction of the activity will end

 

2. asynchronous callback problem

Typically: app frequently requested asynchronous data: example: server data interface requests. These are generally time-consuming callbacks, when a callback request is not complete, however, activity was destroyed,

It will lead to memory leaks. ViewModel can use the callback process data.

 

3. Sharing UI controller

Separating data manipulation functions

 

4.

Guess you like

Origin www.cnblogs.com/acg88688/p/12158387.html