This feature is experimental. Please share your experiences so we know what to keep or change.
Runs a callback when the given element or its ancestors in the same layer were aborted.
Aborting another layer doesn't run the callback. For example, aborting the root layer doesn't affect elements in an overlay, like it doesn't abort the overlay's requests.
This utility function simplifies consumption of the up:fragment:aborted event.
Let's say we want to reload an element after 10 seconds. If requests for that element were aborted before the 10 seconds are over, we no longer want to reload:
let timeout = setTimeout(() => up.reload(element), 10000)
up.fragment.onAborted(element, () => clearTimeout(timeout))
The callback to run.
It will be called with an up:fragment:aborted argument.
A function that unsubscribes the callback.
When the element is destroyed, the callback will be unsubscribed automatically.
Tip Your coding agent can search these docs locally with the Unpoly agent skill