简体   繁体   中英

How to transform a LiveData<List<X>> in LiveData<PagedList<X>>?

有什么方法可以将LiveData<List<X>>类型的对象转换为LiveData<PagedList<X>>类型的对象?

As much as i understood you can do it in the followed way:

    class FirstType
    class SecondType

    val initType: LiveData<FirstType> = MutableLiveData<FirstType>()
    val resultType : LiveData<SecondType> = Transformations.map(initType, ::convertTypes)

    fun convertTypes(firstType: FirstType) : SecondType = SecondType()

upd:
What about converting List<T> to PagedList<T> try to look at:
How to convert a List<Object> to PagedList<Object> and vice-versa?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM