Trigger hook on parent array property
This PR addresses issue https://github.com/livewire/volt/issues/107.
It allows triggering the update hook on the parent array property when a change is made to a key.
Before : When updating on a key, the hook is only triggered for that key.
updated([
'profiles' => function () {
// Not triggered
},
/*'profiles.0' => function () {
// You need to explicitly listen for the key being updated.
// There can be several keys.
// You must listen to them all if you want to take action on any changes made to the parent array.
}*/
]);
With this PR : When updating on a key, the hook is triggered on the parent array, if not explicitly listening for changes to the key.
updated([
'profiles' => function ($key) {
// Triggered, and the modified key is passed as a parameter.
}
]);
That said... I'm wondering whether we should make it more dynamic to handle deep subkey as well.
updated([
'profiles.admin' => function () {
// Triggered on change made to key 'profiles.admin.0'.
}
]);
This PR will forward the hook to the parent property profiles not to profiles.admin.
If we are going to merge this it should probably handle your last case of deep subkeys.
Mark as ready for review again when you want me to take another look please. Thanks!
Added support for deep subkeys. Hope the codebase is still in line with the package behaviour.
Hello @taylorotwell any comment ?
@taylorotwell let me know if there is something you want me to adjust.
@undjike @taylorotwell any updates on this PR?
Any updates here?
Is there any update on this issue?