CBWIRE
InstallSource CodeIssuesSupport
v3.x
v3.x
  • Introduction
  • Getting Started
  • Configuration
  • How It Works
  • Release History
    • What's New With 3.2
    • What's New With 3.1
    • What's New With 3.0
    • What's New With 2.2
    • What's New With 2.1
    • What's New With 2.0
  • Examples
    • Contact Form
    • Multi-select Input
    • File Upload
  • Resources
  • The Essentials
    • Components
    • Templates
    • Data Properties
    • Computed Properties
    • Actions
    • Events
    • Lifecycle Methods
    • JavaScript
    • Testing
  • Wire Features
    • Validation
    • File Uploads
    • Query String
    • Redirecting
    • WireBox
  • Template Features
    • Directives
    • Loading States
    • Polling
    • Prefetching
    • Offline State
    • Defer Loading
    • Dirty State
  • Integrations
    • ContentBox CMS
    • SPAs with Turbo
    • AlpineJS
Powered by GitBook
On this page
  • Method Invocation
  • Stop Polling
  1. Template Features

Polling

Update your components automatically based on a set time interval.

You can add a wire:poll directive to your elements to poll for changes using a set interval. The default interval is set to poll every 2 seconds.

<div wire:poll></div>

You can append a different interval time to your directive as well.

<div wire:poll.5s> <!-- poll every 5 seconds --> </div>

Polling for changes over AJAX can be a reasonable alternative to strategies such as Pusher or WebSockets.

Method Invocation

If you would like to invoke a method during each poll interval, you can do so by specifying a method name.

<cfoutput>
    <div>
        <div wire:poll="refreshTasks"></div>
    </div>
</cfoutput>

<cfscript>
    function refreshTask() {}
</cfscript>

Stop Polling

If you want to stop polling, you can no longer render the HTML element by omitting the wire:poll directive.

<cfif shouldPoll>
    <div wire:poll="refreshTasks"></div>
<cfelse>
    <div><!-- No more polling --></div>
</cfif>
PreviousLoading StatesNextPrefetching

Last updated 1 year ago