Skip to content

Commit ddf0ac9

Browse files
committed
Add support for all polling options
1 parent 3016ed0 commit ddf0ac9

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Support for polling `keep-alive` and `visible`.
10+
711
### Changed
812

913
- Updated Tailwind search clear button (https://github.com/rappasoft/laravel-livewire-tables/pull/217).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ There are some class level properties you can set:
392392
| $searchFilterDebounce | null | null/int | Adds a debounce of `$searchFilterDebounce` ms to the search input |
393393
| $searchFilterDefer | null | null/bool | Adds `.defer` to the search input |
394394
| $searchFilterLazy | null | null/bool | Adds `.lazy` to the search input |
395-
| $refresh | false | false/int/string | Whether or not to refresh the table at a certain interval. false = off, int = ms, string = functionCall |
395+
| $refresh | false | false/int/string | Whether or not to refresh the table at a certain interval. false = off, int = ms, string = functionCall (if the string is `keep-alive` it will use `wire:poll.keep-alive`, if the string is `visible` it will use `wire:poll.visible`) |
396396
| $offlineIndicator | true | bool | Shows a red banner when there is no internet connection. |
397397

398398
#### Using more than one table on a page

resources/views/bootstrap-4/datatable.blade.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<div
2-
@if (is_numeric($refresh)) wire:poll.{{ $refresh }}ms @elseif(is_string($refresh)) wire:poll="{{ $refresh }}" @endif
2+
@if (is_numeric($refresh))
3+
wire:poll.{{ $refresh }}ms
4+
@elseif(is_string($refresh))
5+
@if ($refresh === '.keep-alive' || $refresh === 'keep-alive')
6+
wire:poll.keep-alive
7+
@elseif($refresh === '.visible' || $refresh === 'visible')
8+
wire:poll.visible
9+
@else
10+
wire:poll="{{ $refresh }}"
11+
@endif
12+
@endif
313
class="container-fluid"
414
>
515
@include('livewire-tables::bootstrap-4.includes.offline')

resources/views/bootstrap-5/datatable.blade.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<div
2-
@if (is_numeric($refresh)) wire:poll.{{ $refresh }}ms @elseif(is_string($refresh)) wire:poll="{{ $refresh }}" @endif
2+
@if (is_numeric($refresh))
3+
wire:poll.{{ $refresh }}ms
4+
@elseif(is_string($refresh))
5+
@if ($refresh === '.keep-alive' || $refresh === 'keep-alive')
6+
wire:poll.keep-alive
7+
@elseif($refresh === '.visible' || $refresh === 'visible')
8+
wire:poll.visible
9+
@else
10+
wire:poll="{{ $refresh }}"
11+
@endif
12+
@endif
313
class="container-fluid"
414
>
515
@include('livewire-tables::bootstrap-5.includes.offline')

resources/views/tailwind/datatable.blade.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<div
2-
@if (is_numeric($refresh)) wire:poll.{{ $refresh }}ms @elseif(is_string($refresh)) wire:poll="{{ $refresh }}" @endif
2+
@if (is_numeric($refresh))
3+
wire:poll.{{ $refresh }}ms
4+
@elseif(is_string($refresh))
5+
@if ($refresh === '.keep-alive' || $refresh === 'keep-alive')
6+
wire:poll.keep-alive
7+
@elseif($refresh === '.visible' || $refresh === 'visible')
8+
wire:poll.visible
9+
@else
10+
wire:poll="{{ $refresh }}"
11+
@endif
12+
@endif
313
>
414
@include('livewire-tables::tailwind.includes.offline')
515

src/DataTableComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ abstract class DataTableComponent extends Component
6868
* Whether or not to refresh the table at a certain interval
6969
* false is off
7070
* If it's an integer it will be treated as milliseconds (2000 = refresh every 2 seconds)
71-
* If it's a string it will call that function every 5 seconds.
71+
* If it's a string it will call that function every 5 seconds unless it is 'keep-alive' or 'visible'.
7272
*
7373
* @var bool|string
7474
*/

0 commit comments

Comments
 (0)