Closed james2doyle closed 4 days ago
Looks like the current solution to restarting all the components is:
Livewire.all().map((component) => {
component.call('render'); // or 'restart'
});
https://github.com/livewire/livewire/issues/2334#issuecomment-759901196
If this sounds right, I can make a PR with the changes
if (typeof window.Livewire.restart !== 'function') {
console.info('Patching restart function...');
window.Livewire.restart = () =>
Livewire.all().map((component) => {
// not always defined, depending on the component
if (typeof component.call === 'function') {
return component.call('restart');
}
// will be called when the component is mounted again
if (typeof component.$wire?.$refresh === 'function') {
component.$wire.$refresh();
}
});
}
I wrote this function to patch this now removed restart function. Seems to be working, and I see the endpoints being called when the navigation occurs
Yes, a PR would be fantastic! It would probably also be nice to have a conditional that supports both versions to avoid releasing a major version of the plugin.
@daun Ok cool. My code above has a check for the original function and then just replaces it. I think in the real code it would just be an if/else instead and then call each one natively.
How does that sound?
Sounds perfect!
Closed by #3
What did you expect? π§
Undefined methods should not be called
What actually happened? π΅βπ«
This function being called does not exist
Swup and plugin versions π
What browsers are you seeing the problem on? π§
No response
Relevant log output π€
URL to minimal reproduction π
This would require a hosted Laravel livewire app
Checked all these? π