Kotlin Flow binding APIs for Android's platform and unbundled UI widgets, inspired by RxBinding.
Flow is (conceptually) a reactive streams implementation provided by the kotlinx-coroutines-core artifact.
FlowBinding offers an extensive set of extension functions that turn traditional callbacks / listeners on Android UI widgets into the Flow
type.
The binding implementation respects the CoroutineScope
used for collecting the flows by unregistering the callback / listener automatically when the scope is cancelled.
The library is a work in progress. We currently have bindings for the Material Components and ViewPager2 and we are actively adding more. The ultimate goal is to cover most of the bindings provided by RxBinding plus some of the new widgets from Material Components (e.g. Pickers).
TBA.
- AppBarLayout
-
fun AppBarLayout.offsetChanges(): Flow<Int>
-
- BottomNavigationView
-
fun BottomNavigationView.itemReselections(): Flow<MenuItem>
-
fun BottomNavigationView.itemSelections(emitImmediately: Boolean = false): Flow<MenuItem>
-
- BottomSheetBehavior
-
fun View.bottomSheetSlides(): Flow<Float>
-
fun View.bottomSheetStateChanges(): Flow<Int>
-
- Chip
-
fun Chip.closeIconClicks(): Flow<Unit>
-
- ChipGroup
-
fun ChipGroup.chipCheckedChanges(emitImmediately: Boolean = false): Flow<Int>
-
- MaterialButton
-
fun MaterialButton.checkedChanges(): Flow<Boolean>
-
- MaterialButtonToggleGroup
-
fun MaterialButtonToggleGroup.buttonCheckedChanges(): Flow<MaterialButtonCheckedChangedEvent>
-
- NavigationView
-
fun NavigationView.itemSelections(emitImmediately: Boolean = false): Flow<MenuItem>
-
- Snackbar
-
fun Snackbar.dismissEvents(): Flow<Int>
-
fun Snackbar.shownEvents(): Flow<Unit>
-
- SwipeDismissBehavior
-
fun View.dismisses(): Flow<View>
-
fun View.swipeDismissDragStateChanges(): Flow<Int>
-
- TabLayout
-
fun TabLayout.tabSelectionEvents(emitImmediately: Boolean = false): Flow<TabLayoutSelectionEvent>
-
- Picker - TBA
- Core
TBA.
- AppCompat
TBA.
- DrawerLayout
TBA.
- RecyclerView
TBA.
- SwipeRefreshLayout
TBA.
-
ViewPager 2
-
fun ViewPager2.pageScrollEvents(): Flow<ViewPager2PageScrollEvent>
-
fun ViewPager2.pageScrollStateChanges(): Flow<Int>
-
fun ViewPager2.pageSelections(emitImmediately: Boolean = false): Flow<Int>
-
-
Navigation Component
TBA.
Copyright 2019 Yang Chen
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.