This event is emitted when AJAX requests are taking long to finish.
By default Unpoly will wait 300 ms for an AJAX request to finish
before emitting up:proxy:slow
. You can configure this time like this:
up.proxy.config.slowDelay = 150;
Once all responses have been received, an up:proxy:recover
will be emitted.
Note that if additional requests are made while Unpoly is already busy
waiting, no additional up:proxy:slow
events will be triggered.
You can listen to the up:proxy:slow
and up:proxy:recover
events to implement a spinner
that appears during a long-running request,
and disappears once the response has been received:
<div class="spinner">Please wait!</div>
Here is the JavaScript to make it alive:
up.compiler('.spinner', function(element) {
show = () => { up.element.show(element) }
hide = () => { up.element.hide(element) }
hide()
return [
up.on('up:proxy:slow', show),
up.on('up:proxy:recover', hide)
]
})
The up:proxy:slow
event will be emitted after a delay of 300 ms
to prevent the spinner from flickering on and off.
You can change (or remove) this delay by configuring up.proxy
like this:
up.proxy.config.slowDelay = 150;