CBWIRE
InstallSource CodeIssuesSupport
v2.x
v2.x
  • Introduction
  • Release History
    • What's New With 2.2
    • What's New With 2.1
    • What's New With 2.0
  • Getting Started
  • Examples
  • Essentials
    • Configuration
    • Wires
    • Data Properties
    • Computed Properties
      • Computed Properties ( Proxied )
    • Actions
    • Templates
    • Events & Listeners
    • Wire Lifecycle
    • JavaScript
    • Testing
  • Wire Features
    • Validation
    • File Uploads
    • Query String
    • Redirecting
    • Dependency Injection
  • Template Features
    • Directives
    • Loading States
    • Polling
    • Prefetching
    • Offline State
    • Defer Loading
    • Dirty State
  • Integrations
    • ContentBox CMS
    • Turbo
    • AlpineJS
    • Inline Scripts
Powered by GitBook
On this page
  • Method Invocation
  • Cancel Polling

Was this helpful?

Export as PDF
  1. Template Features

Polling

Poll for state changes based on a specified interval without page refreshes. Hot dog!

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 resonable 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.

<div wire:poll="refreshTasks"></div>
component extends="cbwire.models.Component" {
    
    function refreshTasks() {}
}

Cancel Polling

If you want stop polling, you can simply no longer render the HTML element that has the wire:poll directive.

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

Last updated 3 years ago

Was this helpful?