Skip to content

Commit

Permalink
Add flush state method and register listeners (#3987)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshhanley committed Oct 11, 2021
1 parent 5002f83 commit 72ffd38
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Features/OptimizeRenderedDom.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ function __construct()
$response->effects['html'] = null;
}
});

Livewire::listen('flush-state', function() {
$this->htmlHashesByComponent = [];
});
}
}
4 changes: 4 additions & 0 deletions src/Features/Placeholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ function __construct()
Livewire::listen('component.dehydrate', function ($component, $response) {
//
});

Livewire::listen('flush-state', function() {
//
});
}
}
4 changes: 4 additions & 0 deletions src/Features/SupportActionReturns.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function __construct()

$response->effects['returns'] = $this->returnsByIdAndAction[$component->id];
});

Livewire::listen('flush-state', function() {
$this->returnsByIdAndAction = [];
});
}

function valueIsntAFileResponse($value)
Expand Down
4 changes: 4 additions & 0 deletions src/Features/SupportBrowserHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ function __construct()

$this->getPathFromReferer($referer, $component, $response);
});

Livewire::listen('flush-state', function() {
$this->mergedQueryParamsFromDehydratedComponents = [];
});
}

protected function getRouteFromReferer($referer)
Expand Down
4 changes: 4 additions & 0 deletions src/Features/SupportComponentTraits.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,9 @@ function __construct()
ImplicitlyBoundMethod::call(app(), $method);
}
});

Livewire::listen('flush-state', function() {
$this->componentIdMethodMap = [];
});
}
}
4 changes: 4 additions & 0 deletions src/Features/SupportFileDownloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function __construct()

$response->effects['download'] = $download;
});

Livewire::listen('flush-state', function() {
$this->downloadsById = [];
});
}

function valueIsntAFileResponse($value)
Expand Down
4 changes: 4 additions & 0 deletions src/Features/SupportRedirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@ function __construct()
return;
}
});

Livewire::listen('flush-state', function() {
static::$redirectorCacheStack = [];
});
}
}
7 changes: 7 additions & 0 deletions src/LivewireManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,11 @@ public function shouldDisableBackButtonCache()
{
return $this->shouldDisableBackButtonCache;
}

public function flushState()
{
$this->shouldDisableBackButtonCache = false;

$this->dispatch('flush-state');
}
}

0 comments on commit 72ffd38

Please sign in to comment.