All Projects → sagar-viradiya → callback-ktx

sagar-viradiya / callback-ktx

Licence: Apache-2.0 license
Extension functions over Android's callback-based APIs which allows writing them in a sequential way within coroutines or observe multiple callbacks through kotlin flow.

Programming Languages

kotlin
9241 projects
shell
77523 projects

Projects that are alternatives of or similar to callback-ktx

NewsPin
News app for android using Kotlin, coroutines, MVP architecture
Stars: ✭ 25 (-85.38%)
Mutual labels:  coroutines
modern async cpp example
Just some example code from a lecture about modern async C++
Stars: ✭ 34 (-80.12%)
Mutual labels:  coroutines
redmadrobot-android-ktx
Missing Android KTX extensions.
Stars: ✭ 27 (-84.21%)
Mutual labels:  ktx
SuspendActivityResult
A lightweight library for requesting and consuming Activity Results using coroutines.
Stars: ✭ 71 (-58.48%)
Mutual labels:  coroutines
kotlin-kafka-and-kafka-streams-examples
Kafka with KafkaReactor and Kafka Streams Examples in Kotlin
Stars: ✭ 33 (-80.7%)
Mutual labels:  coroutines
AvengersChat
💙 Android sample Avengers chat application using Stream Chat SDK based on MVVM (ViewModel, Coroutines, Room, Hilt, Repository) architecture.
Stars: ✭ 350 (+104.68%)
Mutual labels:  coroutines
CoroutineLite
Simple implementation of kotlinx.coroutines to clarify the design of Kotlin Coroutines.
Stars: ✭ 142 (-16.96%)
Mutual labels:  coroutines
qcoro
C++ Coroutines for Qt
Stars: ✭ 150 (-12.28%)
Mutual labels:  coroutines
floppy
🧩 Handling and maintain your UI view component easily
Stars: ✭ 55 (-67.84%)
Mutual labels:  coroutines
ResDelivery-Hilt-Coroutines-Mvvm-Single-Activity
This is a Sample Single Activity App (Multi Fragments) that uses Dagger-Hilt, Coroutines Flows, Paging 3 & Mvvm Clean Architecture
Stars: ✭ 28 (-83.63%)
Mutual labels:  coroutines
algoliasearch-client-kotlin
⚡️ A fully-featured and blazing-fast Kotlin/Android API client to interact with Algolia.
Stars: ✭ 45 (-73.68%)
Mutual labels:  coroutines
StarWarsSearch-MVI
Star wars sample android project showcasing the use of View components for rendering UI in Fragments and Activities. Uses Android Jetpack, clean architecture with MVI (Uni-directional data flow), dagger hilt, and kotlin coroutines with StateFlow
Stars: ✭ 189 (+10.53%)
Mutual labels:  coroutines
FoodApp
Proof of concept for food app [JetPack + Coroutines + Flow + MockK + JaCoCo coverage + SonarQube]
Stars: ✭ 25 (-85.38%)
Mutual labels:  coroutines
KotlinEverywhere
This application created for Kotlin Everywhere series as a codelab. It will show step by step Kotlin and Android Jetpack Components fundamentals. 🚀🚀
Stars: ✭ 52 (-69.59%)
Mutual labels:  coroutines
kotlin-coroutines-android
Useful extensions for coroutines. AutoDispose + MainScope
Stars: ✭ 84 (-50.88%)
Mutual labels:  coroutines
StatefulLiveData
StatefulLiveData is a lean, yet powerful tool that harnesses the capabilities of LiveData and enhances them, enabling the observer to distinguish between different states the data can be in, such as Success, Loading and Error.
Stars: ✭ 18 (-89.47%)
Mutual labels:  coroutines
DemOS
Free, simple, extremely lightweight, stackless, cooperative, co-routine system (OS) for microcontrollers
Stars: ✭ 18 (-89.47%)
Mutual labels:  coroutines
Sunset-hadith
Islamic app written with Kotlin, using KTOR + coroutines + flow + MVVM + Android Jetpack + Navigation component. Old version using RxJava + Retrofit + OKHttp
Stars: ✭ 26 (-84.8%)
Mutual labels:  coroutines
Android-Assignment
This assignment gives you basically a post list and its detail with comments.🚀
Stars: ✭ 32 (-81.29%)
Mutual labels:  coroutines
NoMansWallpaperApp
Looking for your next No Man's Sky wallpaper?
Stars: ✭ 35 (-79.53%)
Mutual labels:  coroutines

callback-ktx

CI

A lightweight Android library that wraps Android's callback-based APIs into suspending extension functions which allow writing them in a sequential way within coroutines or observe multiple callbacks through Kotlin flow. This library is inspired by Chris Banes blog on suspending over view.

Currently covers following APIs

  • Animation
  • Location
  • RecyclerView
  • Sensor
  • View
  • Widget(TextView)

Including in your project

Callback extensions are divided across different modules based on the category they fall under. For example, all framework APIs would fall under the core module. Anything not related to the framework is in its separate module. So depending on your requirement you can depend on a specific module available on mavenCentral()

To include core extension add the following in your build.gradle

implementation("io.github.sagar-viradiya:callback-core-ktx:1.0.0")

Similarly, you can check individual module's README to know how to include those dependencies.

Examples

Below are a few examples of the extensions and it's usage in coroutine.

Await on animation start (Core extension)

viewLifecycleOwner.lifecycleScope.launch {
  animator.awaitStart()
  // Your code goes here after animation start
}

Await view's layout. If a view is already laid out it will resume coroutine immediately otherwise suspends till the next view layout. The extension takes care of removing the listener internally.

viewLifecycleOwner.lifecycleScope.launch {
  view.awaitDoOnLayout()
  // Do things after view laid out
}

Await on the last location.

viewLifecycleOwner.lifecycleScope.launch {
  val location = fusedLocationProviderClient.awaitLastLocation()    // Suspend coroutine
  // Use last location
}

Observe location changes. The extension takes care of registering and unregistering location update callback based on the state of the lifecycle owner internally.

viewLifecycleOwner.lifecycleScope.launch {
  fusedLocationProviderClient.locationFlow(locationRequest, lifecycleOwner).collect { location ->
    // Consume location
  }
}

Please check the individual module's README for more details.

Contributing

Found APIs that are not covered and want to contribute new extensions? Found an issue or have any suggestions for enhancements? Head over to Contribution guidelines to know more about contributing to this library.

License

Copyright 2021 callback-ktx contributors

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].