From 3d2036bdc32fa64996fc68f27b68565771877440 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Mon, 19 Dec 2022 20:10:00 +0300 Subject: [PATCH] Add ability to clear plending navigation commands --- .../kotlin/com/github/terrakok/cicerone/CommandBuffer.kt | 4 ++++ .../kotlin/com/github/terrakok/cicerone/NavigatorHolder.kt | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/library/src/main/kotlin/com/github/terrakok/cicerone/CommandBuffer.kt b/library/src/main/kotlin/com/github/terrakok/cicerone/CommandBuffer.kt index fa51a85..9cfdc79 100644 --- a/library/src/main/kotlin/com/github/terrakok/cicerone/CommandBuffer.kt +++ b/library/src/main/kotlin/com/github/terrakok/cicerone/CommandBuffer.kt @@ -22,6 +22,10 @@ internal class CommandBuffer : NavigatorHolder { navigator = null } + override fun clearPendingCommands() { + pendingCommands.clear() + } + /** * Passes `commands` to the [Navigator] if it available. * Else puts it to the pending commands queue to pass it later. diff --git a/library/src/main/kotlin/com/github/terrakok/cicerone/NavigatorHolder.kt b/library/src/main/kotlin/com/github/terrakok/cicerone/NavigatorHolder.kt index fa6ed5e..9e6507f 100644 --- a/library/src/main/kotlin/com/github/terrakok/cicerone/NavigatorHolder.kt +++ b/library/src/main/kotlin/com/github/terrakok/cicerone/NavigatorHolder.kt @@ -17,4 +17,9 @@ interface NavigatorHolder { * Remove the current Navigator and stop receive commands. */ fun removeNavigator() + + /** + * Clear pending commands. + */ + fun clearPendingCommands() }