ReactiveLiveData: LiveData Transformation Features Overview
ReactiveLiveData enhances LiveData with essential transformation capabilities such as map, switchMap, switchLatest, filterNotNull, distinctUntilChanged, merge, combineLatest, startWith, first, takeUntil, takeWhile, buffer, cast, and more. For instance, filtering a LiveData source to emit only odd numbers can be achieved with `filter`. Example: `val source: LiveData = ... // 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
source.filter { it % 2 == 1 }.observe(this) { println(it) } // outputs 1, 3, 5, 7, 9`
source.filter { it % 2 == 1 }.observe(this) { println(it) } // outputs 1, 3, 5, 7, 9`
70.64KB
文件大小:
评论区