Repository navigation
Replies: 1 comment
|
Part of this works today. Each sequence registration reports const registrations = useHotkeyRegistrations()
const pending = registrations.find(
(reg) => reg.kind === 'sequence' && reg.matchedStepCount > 0,
)
// Show the overlay while `pending` is setThis is the store subscription you mentioned, wrapped in a hook. There are no |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, I'd like to add support for lifecycle callbacks on sequences.
Specifically, I want to create transient UI like a "press the next key…" overlay that shows up the moment the user starts a sequence and disappears the moment they bail or time out.
I believe, today the only signal is the completion callback. The best way I could find to achieve this today would be subscribing to the manager's store.
I'd be happy to create PR.
API proposal
Three new optional fields on
SequenceOptions:onStartfires when a multi-step sequence advances past its first step. Single-step sequences don't fire it (they complete immediately).onCancelfires when the configuredtimeoutbetween steps elapses without further input, or when the sequence is interrupted. Sequence can be interrupted by when a non-matching key arrives mid-sequence, or when something changes programmatically (such asenabledflipping fromtruetofalse)Right now, "timeout" is only checked when another key is pressed. To track
onCancelcallback, we'd have to schedule actual timeout viasetTimeout. To keep the overhead to minimal, we only schedule it whenonCancelis actually provided.I also considered returning sort of
inProgressstate from the hook, but I don't believe this is correct solution, as we'd be paying the overhead even when 99% of usecases don't need it.All reactions