Skip to content

Commit

Permalink
feat: add useHideButtons hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ShindouMihou committed Oct 29, 2023
1 parent cfc8be6 commit 178a44d
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package pw.mihou.nexus.features.react.hooks

import pw.mihou.nexus.Nexus
import pw.mihou.nexus.configuration.modules.Cancellable
import pw.mihou.nexus.features.react.React
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes

fun React.useHideButtons(after: Duration = 10.minutes): React.Writable<Boolean> {
val showButtons = writable(true)
var removeButtons: Cancellable? = null

onRender {
removeButtons?.cancel(true)
removeButtons = Nexus.launch.scheduler.launch(after.inWholeMilliseconds) {
showButtons.set(false)
}
}

return showButtons
}

0 comments on commit 178a44d

Please sign in to comment.