Skip to content

Commit 233bda4

Browse files
committed
refactor(Rime): check current state on init
1 parent f5fe60d commit 233bda4

File tree

1 file changed

+6
-0
lines changed
  • app/src/main/java/com/osfans/trime/core

1 file changed

+6
-0
lines changed

app/src/main/java/com/osfans/trime/core/Rime.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ class Rime :
6363
},
6464
)
6565

66+
init {
67+
if (lifecycle.currentStateFlow.value != RimeLifecycle.State.STOPPED) {
68+
throw IllegalStateException("Rime has already been created!")
69+
}
70+
}
71+
6672
private suspend inline fun <T> withRimeContext(crossinline block: suspend () -> T): T = withContext(dispatcher) {
6773
block()
6874
}

0 commit comments

Comments
 (0)