Skip to main content

TimeoutController

Purpose

Utility controller to wire up other controller actions that need to fire after an elapsed time.

Actions

ActionPurpose
--

Targets

TargetPurposeDefault
---

Classes

ClassPurposeDefault
---

Values

ValueTypeDescriptionDefault
secondsNumberThe number of seconds until the action fires-

Events

EventWhenDispatched onevent.detail
timeout:actionFired after secondsValue seconds, used to wire your desired controller actions tothe controller root elementelement: the controller root element

Side Effects

Calls setTimeout with the desired timeout. Cleans up on disconnect if that happens before timeout occurs.

How to Use

An example: Show a marketing popup after 30 seconds.

<div data-controller="popup dismissable" data-action="timeout:action->popup#open">
<meta data-controller="timeout" data-timeout-seconds-value="30" />
<p>Sign up to get great deals!</p>

<a data-action="click->dismissable#dismiss">No thanks</a>
</div>