mixhtml

INTERVAL

Interval

Using an interval allows a fetch request to be triggered continiously as defined in the interval in milliseconds. In web terms, this is short polling.

Usually an interval is supposed to run as long as the page is open, but there is a way to stop/clear the interval.

In the following example, the notification with the counter is always changing. That is because an interval has been set when the page was loaded. The following code can be used to set an interval. The tag has no relevance, only the attributes mix-interval and mix-get.

    <div id="test" 
        mix-interval="5000" 
        mix-get="total-notifications">
    </div>

The interval can be stopped by clicking on the "Stop interval" button.

2

Request

<button 
    mix-get="stop-interval/%23test"
>
    Stop interval
</button>

Response

<browser 
    mix-stop-interval="#test"
>
</browser>