Skip to content

Repository files navigation

RxDiffUtil

Download

Download

implementation 'be.mickverm.rxjava2:rxdiffutil:1.1.0'

Usage

class RecyclerViewAdapter : RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder>(), 
    Consumer<Pair<List<Item>, DiffUtil.DiffResult> {

    private var items = listOf<Item>()

    override fun accept(pair: Pair<List<Item>, DiffUtil.DiffResult>) {
        items = pair.first
        pair.second.dispatchUpdatesTo(this)
    }
}

or

class RecyclerViewAdapter : RxDiffUtilAdapter<Item, ItemRecyclerViewAdapter.ViewHolder>() {

}
database.observableItems
	.subscribeOn(Schedulers.io())
	.observeOn(Schedulers.computation())
	.compose(RxDiffUtil.calculateObservable(::ItemDiffCallback))
	.observeOn(AndroidSchedulers.mainThread())
	.subscribe(recyclerViewAdapter)

database.flowableItems
	.subscribeOn(Schedulers.io())
	.observeOn(Schedulers.computation())
	.compose(RxDiffUtil.calculateFlowable(::ItemDiffCallback))
	.observeOn(AndroidSchedulers.mainThread())
	.subscribe(recyclerViewAdapter)

License

Copyright 2020 Michiel Vermeersch

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages