kotlinx.coroutines v1.4.0-M1 Release Notes

  • ๐Ÿ’ฅ Breaking changes

    • ๐Ÿšš The concept of atomic cancellation in channels is removed. All operations in channels and corresponding Flow operators are cancellable in non-atomic way (#1813).
    • โฑ If CoroutineDispatcher throws RejectedExecutionException, cancel current Job and schedule its execution to Dispatchers.IO (#2003).
    • CancellableContinuation.invokeOnCancellation is invoked if the continuation was cancelled while its resume has been dispatched (#1915).
    • Flow.singleOrNull operator is aligned with standard library and does not longer throw IllegalStateException on multiple values (#2289).

    ๐Ÿ†• New experimental features

    • ๐Ÿ”Š SharedFlow primitive for managing hot sources of events with support of various subscription mechanisms, replay logs and buffering (#2034).
    • Flow.shareIn and Flow.stateIn operators to transform cold instances of flow to hot SharedFlow and StateFlow respectively (#2047).

    Other

    • ๐Ÿ‘Œ Support leak-free closeable resources transfer via onUndeliveredElement in channels (#1936).
    • ๐Ÿ”„ Changed ABI in reactive integrations for Java interoperability (#2182).
    • ๐Ÿ›  Fixed ProGuard rules for kotlinx-coroutines-core (#2046, #2266).
    • ๐Ÿ‘• Lint settings were added to Flow to avoid accidental capturing of outer CoroutineScope for cancellation check (#2038).

    External contributions

    • ๐Ÿ‘ Allow nullable types in Flow.firstOrNull and Flow.singleOrNull by @ansman (#2229).
    • โž• Add Publisher.awaitSingleOrDefault|Null|Else extensions by @sdeleuze (#1993).
    • awaitCancellation top-level function by @LouisCAD (#2213).
    • ๐Ÿ— Significant part of our Gradle build scripts were migrated to .kts by @turansky.

    Thank you for your contributions and participation in the Kotlin community!