livewire / volt

Volt is an elegantly crafted functional API for Livewire.
https://livewire.laravel.com/docs/volt
MIT License
339 stars 19 forks source link

Updated hook not triggered on array property #107

Open undjike opened 3 months ago

undjike commented 3 months ago

Volt Version

1.6.3

Laravel Version

11.7.0

PHP Version

8.3.8

Database Driver & Version

Not applicable

Description

updated([
    'profiles' => function () {
        // Not triggered
    },
    'profiles.0' => function () {
        // Triggered when key 0 changed
    }
]);
@foreach(Profile::cases() as $profile)
      <input type="checkbox"
                  wire:model.live="profiles"
                  value="{{ $profile->name }}"
                  class="sr-only peer"
                  id="user-assigned-{{ $profile->name }}">
@endforeach

The problem is there could be several keys in the array and I don't know which might change. I want to track any changes on the array an execute an action.

Steps To Reproduce

Create a Volt component an listen to the updated hook on an array property (wired to a checkbox in this case).