-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e61ac7
commit 6136807
Showing
10 changed files
with
135 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Defer Loading | ||
|
||
If the query to fetch your data takes a while, it will delay the page from loading. By default, deferred loading is not enabled. | ||
|
||
By enabling this feature the records will be fetched after the page has finished loading. | ||
|
||
```php | ||
protected bool $deferLoading = true; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace RamonRietdijk\LivewireTables\Concerns; | ||
|
||
trait HasDeferredLoading | ||
{ | ||
protected bool $deferLoading = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace RamonRietdijk\LivewireTables\Concerns; | ||
|
||
trait HasInitialization | ||
{ | ||
public bool $initialized = false; | ||
|
||
public function init(): void | ||
{ | ||
$this->initialized = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/Fakes/Http/Livewire/DeferredLoadingBlogLivewireTable.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace RamonRietdijk\LivewireTables\Tests\Fakes\Http\Livewire; | ||
|
||
use RamonRietdijk\LivewireTables\Http\Livewire\LivewireTable; | ||
use RamonRietdijk\LivewireTables\Tests\Fakes\Models\Blog; | ||
|
||
class DeferredLoadingBlogLivewireTable extends LivewireTable | ||
{ | ||
protected string $model = Blog::class; | ||
|
||
protected bool $deferLoading = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace RamonRietdijk\LivewireTables\Tests\Integration\Concerns; | ||
|
||
use Livewire\Livewire; | ||
use RamonRietdijk\LivewireTables\Tests\Fakes\Http\Livewire\DeferredLoadingBlogLivewireTable; | ||
use RamonRietdijk\LivewireTables\Tests\TestCase; | ||
|
||
class HasDeferredLoadingTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_defer_loading(): void | ||
{ | ||
Livewire::test(DeferredLoadingBlogLivewireTable::class) | ||
->assertSee('Fetching records...') | ||
->call('init') | ||
->assertDontSee('Fetching records...'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace RamonRietdijk\LivewireTables\Tests\Integration\Concerns; | ||
|
||
use Livewire\Livewire; | ||
use RamonRietdijk\LivewireTables\Tests\Fakes\Http\Livewire\BlogLivewireTable; | ||
use RamonRietdijk\LivewireTables\Tests\TestCase; | ||
|
||
class HasInitializationTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_be_initialized(): void | ||
{ | ||
Livewire::test(BlogLivewireTable::class) | ||
->assertSet('initialized', false) | ||
->call('init') | ||
->assertSet('initialized', true); | ||
} | ||
} |