Skip to content

Commit

Permalink
introduce the concept of ignore first load
Browse files Browse the repository at this point in the history
  • Loading branch information
joetannenbaum committed Jul 18, 2024
1 parent 8edbd02 commit 4be6289
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/DeferProp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Support\Facades\App;

class DeferProp
class DeferProp implements IgnoreFirstLoad
{
protected $callback;

Expand Down
8 changes: 8 additions & 0 deletions src/IgnoreFirstLoad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Inertia;

interface IgnoreFirstLoad
{
//
}
2 changes: 1 addition & 1 deletion src/LazyProp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Support\Facades\App;

class LazyProp
class LazyProp implements IgnoreFirstLoad
{
protected $callback;

Expand Down
2 changes: 1 addition & 1 deletion src/OptionalProp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Support\Facades\App;

class OptionalProp
class OptionalProp implements IgnoreFirstLoad
{
protected $callback;

Expand Down
2 changes: 1 addition & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function resolveProperties(Request $request, array $props): array

if (! $isPartial) {
$props = array_filter($this->props, static function ($prop) {
return ! ($prop instanceof OptionalProp) && ! ($prop instanceof LazyProp) && ! ($prop instanceof DeferProp);
return ! ($prop instanceof IgnoreFirstLoad);
});
}

Expand Down

0 comments on commit 4be6289

Please sign in to comment.