본문 바로가기

기타개발32

Coroutines - Flow #4 : Exceptions, completions, cancellation https://kotlinlang.org/docs/reference/coroutines/flow.html Asynchronous Flow - Kotlin Programming Language kotlinlang.org 1. Flow exceptions 연산자 내부의 emitter 또는 코드에서 예외가 발생하면 flow collection 이 예외로 완료 할 수 있다. fun simple(): Flow = flow { for (i in 1..3) { println("Emitting $i") emit(i) // emit next value } } fun main() = runBlocking { try { simple().collect { value -> println(value) check(value che.. 2020. 7. 27.
Coroutines - Flow #3 : Composing and flattening flows https://kotlinlang.org/docs/reference/coroutines/flow.html Asynchronous Flow - Kotlin Programming Language kotlinlang.org 1. Composing multiple flows Zip 두 flow 값을 결합하며 둘 중 작은 개수에 맞춰 결과 개수도 리턴된다 val nums = (1..3).asFlow() // numbers 1..3 val strs = flowOf("one", "two", "three") // strings nums.zip(strs) { a, b -> "$a -> $b" } // compose a single string .collect { println(it) } // collect and pri.. 2020. 7. 27.
Coroutines - Flow #2 : Buffering https://kotlinlang.org/docs/reference/coroutines/flow.html Asynchronous Flow - Kotlin Programming Language kotlinlang.org 1. Buffer 일반적으로 flow 는 아래 예제처럼 순차적이며 모든 연산자의 코드가 동일한 코루틴에서 실행됨을 의미한다 flowOf("A", "B", "C") .onEach { println("1$it") } .collect { println("2$it") } /** * 결과 * * Q : -->-- [1A] -- [2A] -- [1B] -- [2B] -- [1C] -- [2C] -->-- */ 따라서 연산자 내 코드를 실행하는 데 상당한 시간이 걸리게되면 총 실행 시간은 모든 연산자 .. 2020. 7. 21.
Coroutines - Flow #1 : Flow builders, operators, context https://kotlinlang.org/docs/reference/coroutines/flow.html Asynchronous Flow - Kotlin Programming Language kotlinlang.org Suspend function : 비동기로 단일 값을 반환 Kotlin Flows : 비동기로 여러 값을 반환 1. Representing multiple values Collection fun foo(): List = listOf(1, 2, 3) fun main() { foo().forEach { value -> println(value) } } Sequence : Collection 의 결과와 같지만, 100ms 간격으로 값을 출력하며 메인 스레드 blocking 한다. fun foo(.. 2020. 7. 9.
RxJava - What's different in 3.0 RxJava 란 비동기 및 이벤트 기반 프로그래밍을 가능하게 해주는 라이브러리 이제 2.x 버전은 유지보수 모드로 버그 픽스만 적용될 뿐 새로운 기능 업데이트는 없으며, 2021년 3월부터는 모든 개발 중단! 참고) https://github.com/ReactiveX/RxJava/wiki/What's-different-in-3.0 1. Gradle import dependencies { implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' // https://github.com/ReactiveX/RxAndroid implementation 'io.reactivex.rxjava3:rxjava:3.0.0' // https://github.com/ReactiveX/R.. 2020. 6. 23.
GitHub Actions #8 - Authenticating with the GITHUB_TOKEN # GitHub Actions 번역하며 요약하기 https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token Authenticating with the GITHUB_TOKEN - GitHub Help Authenticating with the GITHUB_TOKEN GitHub provides a token that you can use to authenticate on behalf of GitHub Actions. GitHub Actions is available with GitHub Free, GitHub Pro, GitHub Team, GitHub Enterprise C.. 2020. 3. 31.