Preempt Disable
Disable a control in the browser the instant it's clicked, before the round trip to the server even starts.
Overview
Every click normally has to travel to the server and a diff has to come back before the browser reflects anything. For a button that shouldn't be clicked twice — a submit button, a "Like" button — that round trip is exactly the window where a second click sneaks through. hlivekit.PreemptDisableOn wraps an event binding so its element is disabled in the browser's DOM before the click event is even sent to the server, closing that window entirely, and then updates the page's own state to match once the handler runs.
API
hlivekit.PreemptDisableOn(eb *l.EventBinding) *l.ElementGroup— wrap a click binding so its component disables itself the instant it's clicked.
Use case
A checkout "Place Order" button behind a slow payment call: without preempt-disable, an impatient double-click can fire the handler twice before the first response comes back. Disabling the button on the very first click removes that failure mode without you writing any client-side debounce logic.
Code sample
Adapted from the Preempt example:
Button("Place Order",
hlivekit.PreemptDisableOn(l.On("click", func(ctx context.Context, e l.Event) {
// The button is already disabled in the browser by the time
// this handler starts running.
placeOrder()
})),
)