Filter list of objects in RxJava

后端 未结 4 1698
南方客
南方客 2021-02-13 07:00

I am trying to filter the list on the basis of it\'s property. For example, Sensors class has a property isActive and I want to get all the objects with isAct

4条回答
  •  失恋的感觉
    2021-02-13 07:30

    I wanted to delete the values of a list based on Rejex and finally return a Observable list model

    fun getList(): Observable> {
        return appDataBase.dao().getAllList().flatMap {
            Observable.fromIterable(it).filter { destination ->
                destination.number.matches(regex = "[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s\\./0-9]*\$".toRegex())
            }.toList().toObservable()
        }.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
    
    }
    

    I hope this helps

提交回复
热议问题