Merge pull request #72 from InsanusMokrassar/0.5.8

0.5.8
This commit is contained in:
InsanusMokrassar 2021-06-11 22:36:40 +06:00 committed by GitHub
commit fa30aae194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 2 deletions

12
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,12 @@
name: Regular build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build
run: ./gradlew build

View File

@ -1,5 +1,14 @@
# Changelog
## 0.5.8
* `Common`:
* New extension `Iterable#firstNotNull`
* `Coroutines`
* New extension `Flow#firstNotNull`
* New extensions `CoroutineContext#LinkedSupervisorJob`, `CoroutineScope#LinkedSupervisorJob` and
`CoroutineScope#LinkedSupervisorScope`
## 0.5.7
* `Pagination`

View File

@ -0,0 +1,3 @@
package dev.inmo.micro_utils.common
fun <T> Iterable<T?>.firstNotNull() = first { it != null }!!

View File

@ -0,0 +1,6 @@
package dev.inmo.micro_utils.coroutines
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
suspend fun <T> Flow<T?>.firstNotNull() = first { it != null }!!

View File

@ -0,0 +1,17 @@
package dev.inmo.micro_utils.coroutines
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
fun CoroutineContext.LinkedSupervisorJob(
additionalContext: CoroutineContext? = null
) = SupervisorJob(job).let { if (additionalContext != null) it + additionalContext else it }
fun CoroutineScope.LinkedSupervisorJob(
additionalContext: CoroutineContext? = null
) = coroutineContext.LinkedSupervisorJob(additionalContext)
fun CoroutineScope.LinkedSupervisorScope(
additionalContext: CoroutineContext? = null
) = CoroutineScope(
coroutineContext + LinkedSupervisorJob(additionalContext)
)

View File

@ -45,5 +45,5 @@ dokka_version=1.4.32
# Project data
group=dev.inmo
version=0.5.7
android_code_version=48
version=0.5.8
android_code_version=49