Skip to content

Commit 2d39ef3

Browse files
authored
Merge pull request #965 from arkivanov/onDecomposeError
Added DecomposeSettings#onDecomposeError, deprecated onDecomposeError
2 parents 609ef69 + da40668 commit 2d39ef3

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

decompose/api/android/decompose.api

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,17 @@ public final class com/arkivanov/decompose/DecomposeExperimentFlags {
7171
public final class com/arkivanov/decompose/DecomposeSettings {
7272
public static final field Companion Lcom/arkivanov/decompose/DecomposeSettings$Companion;
7373
public fun <init> ()V
74-
public fun <init> (ZZ)V
75-
public synthetic fun <init> (ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
74+
public fun <init> (ZZLkotlin/jvm/functions/Function1;)V
75+
public synthetic fun <init> (ZZLkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
7676
public final fun component1 ()Z
7777
public final fun component2 ()Z
78-
public final fun copy (ZZ)Lcom/arkivanov/decompose/DecomposeSettings;
79-
public static synthetic fun copy$default (Lcom/arkivanov/decompose/DecomposeSettings;ZZILjava/lang/Object;)Lcom/arkivanov/decompose/DecomposeSettings;
78+
public final fun component3 ()Lkotlin/jvm/functions/Function1;
79+
public final fun copy (ZZLkotlin/jvm/functions/Function1;)Lcom/arkivanov/decompose/DecomposeSettings;
80+
public static synthetic fun copy$default (Lcom/arkivanov/decompose/DecomposeSettings;ZZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/arkivanov/decompose/DecomposeSettings;
8081
public fun equals (Ljava/lang/Object;)Z
8182
public final fun getDuplicateConfigurationsEnabled ()Z
8283
public final fun getMainThreadCheckEnabled ()Z
84+
public final fun getOnDecomposeError ()Lkotlin/jvm/functions/Function1;
8385
public fun hashCode ()I
8486
public fun toString ()Ljava/lang/String;
8587
}

decompose/api/decompose.klib.api

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,16 +483,19 @@ final class <#A: out kotlin/Any> com.arkivanov.decompose.router.pages/Pages { //
483483
}
484484

485485
final class com.arkivanov.decompose/DecomposeSettings { // com.arkivanov.decompose/DecomposeSettings|null[0]
486-
constructor <init>(kotlin/Boolean = ..., kotlin/Boolean = ...) // com.arkivanov.decompose/DecomposeSettings.<init>|<init>(kotlin.Boolean;kotlin.Boolean){}[0]
486+
constructor <init>(kotlin/Boolean = ..., kotlin/Boolean = ..., kotlin/Function1<kotlin/Exception, kotlin/Unit> = ...) // com.arkivanov.decompose/DecomposeSettings.<init>|<init>(kotlin.Boolean;kotlin.Boolean;kotlin.Function1<kotlin.Exception,kotlin.Unit>){}[0]
487487

488488
final val duplicateConfigurationsEnabled // com.arkivanov.decompose/DecomposeSettings.duplicateConfigurationsEnabled|{}duplicateConfigurationsEnabled[0]
489489
final fun <get-duplicateConfigurationsEnabled>(): kotlin/Boolean // com.arkivanov.decompose/DecomposeSettings.duplicateConfigurationsEnabled.<get-duplicateConfigurationsEnabled>|<get-duplicateConfigurationsEnabled>(){}[0]
490490
final val mainThreadCheckEnabled // com.arkivanov.decompose/DecomposeSettings.mainThreadCheckEnabled|{}mainThreadCheckEnabled[0]
491491
final fun <get-mainThreadCheckEnabled>(): kotlin/Boolean // com.arkivanov.decompose/DecomposeSettings.mainThreadCheckEnabled.<get-mainThreadCheckEnabled>|<get-mainThreadCheckEnabled>(){}[0]
492+
final val onDecomposeError // com.arkivanov.decompose/DecomposeSettings.onDecomposeError|{}onDecomposeError[0]
493+
final fun <get-onDecomposeError>(): kotlin/Function1<kotlin/Exception, kotlin/Unit> // com.arkivanov.decompose/DecomposeSettings.onDecomposeError.<get-onDecomposeError>|<get-onDecomposeError>(){}[0]
492494

493495
final fun component1(): kotlin/Boolean // com.arkivanov.decompose/DecomposeSettings.component1|component1(){}[0]
494496
final fun component2(): kotlin/Boolean // com.arkivanov.decompose/DecomposeSettings.component2|component2(){}[0]
495-
final fun copy(kotlin/Boolean = ..., kotlin/Boolean = ...): com.arkivanov.decompose/DecomposeSettings // com.arkivanov.decompose/DecomposeSettings.copy|copy(kotlin.Boolean;kotlin.Boolean){}[0]
497+
final fun component3(): kotlin/Function1<kotlin/Exception, kotlin/Unit> // com.arkivanov.decompose/DecomposeSettings.component3|component3(){}[0]
498+
final fun copy(kotlin/Boolean = ..., kotlin/Boolean = ..., kotlin/Function1<kotlin/Exception, kotlin/Unit> = ...): com.arkivanov.decompose/DecomposeSettings // com.arkivanov.decompose/DecomposeSettings.copy|copy(kotlin.Boolean;kotlin.Boolean;kotlin.Function1<kotlin.Exception,kotlin.Unit>){}[0]
496499
final fun equals(kotlin/Any?): kotlin/Boolean // com.arkivanov.decompose/DecomposeSettings.equals|equals(kotlin.Any?){}[0]
497500
final fun hashCode(): kotlin/Int // com.arkivanov.decompose/DecomposeSettings.hashCode|hashCode(){}[0]
498501
final fun toString(): kotlin/String // com.arkivanov.decompose/DecomposeSettings.toString|toString(){}[0]

decompose/api/jvm/decompose.api

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,17 @@ public final class com/arkivanov/decompose/DecomposeExperimentFlags {
7171
public final class com/arkivanov/decompose/DecomposeSettings {
7272
public static final field Companion Lcom/arkivanov/decompose/DecomposeSettings$Companion;
7373
public fun <init> ()V
74-
public fun <init> (ZZ)V
75-
public synthetic fun <init> (ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
74+
public fun <init> (ZZLkotlin/jvm/functions/Function1;)V
75+
public synthetic fun <init> (ZZLkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
7676
public final fun component1 ()Z
7777
public final fun component2 ()Z
78-
public final fun copy (ZZ)Lcom/arkivanov/decompose/DecomposeSettings;
79-
public static synthetic fun copy$default (Lcom/arkivanov/decompose/DecomposeSettings;ZZILjava/lang/Object;)Lcom/arkivanov/decompose/DecomposeSettings;
78+
public final fun component3 ()Lkotlin/jvm/functions/Function1;
79+
public final fun copy (ZZLkotlin/jvm/functions/Function1;)Lcom/arkivanov/decompose/DecomposeSettings;
80+
public static synthetic fun copy$default (Lcom/arkivanov/decompose/DecomposeSettings;ZZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/arkivanov/decompose/DecomposeSettings;
8081
public fun equals (Ljava/lang/Object;)Z
8182
public final fun getDuplicateConfigurationsEnabled ()Z
8283
public final fun getMainThreadCheckEnabled ()Z
84+
public final fun getOnDecomposeError ()Lkotlin/jvm/functions/Function1;
8385
public fun hashCode ()I
8486
public fun toString ()Ljava/lang/String;
8587
}

decompose/src/commonMain/kotlin/com/arkivanov/decompose/DecomposeSettings.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.arkivanov.decompose
22

3+
import com.arkivanov.decompose.errorhandler.printError
34
import kotlin.concurrent.Volatile
45

56
/**
@@ -10,10 +11,12 @@ import kotlin.concurrent.Volatile
1011
* @param mainThreadCheckEnabled controls whether main thread checks are enabled or not.
1112
* If enabled, Decompose will log an error if it detects access from a background thread when it was expected from the main thread.
1213
* Default value is `true`.
14+
* @param onDecomposeError called when a non-fatal error has occurred in Decompose. By default, prints the error to logs.
1315
*/
1416
data class DecomposeSettings(
1517
val duplicateConfigurationsEnabled: Boolean = false,
1618
val mainThreadCheckEnabled: Boolean = true,
19+
val onDecomposeError: (Exception) -> Unit = ::printError,
1720
) {
1821

1922
companion object {
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package com.arkivanov.decompose.errorhandler
22

3+
import com.arkivanov.decompose.DecomposeSettings
4+
35
/**
46
* Called when a non-fatal error has occurred in Decompose.
57
*/
6-
var onDecomposeError: (Exception) -> Unit = ::printError
8+
@Deprecated(message = "Please use DecomposeSettings#onDecomposeError")
9+
var onDecomposeError: (Exception) -> Unit
10+
get() = DecomposeSettings.settings.onDecomposeError
11+
set(value) {
12+
DecomposeSettings.update { it.copy(onDecomposeError = value) }
13+
}

0 commit comments

Comments
 (0)