I have a use case where I have some data (let’s say a burger menu) and I have a filters component (let’s say filter by ingredient) that should be used to filter through the data. How should one go about building this using Livewire?
Here’s what I’ve come up with: the filters component internally keeps a json representation of the filters (eg. a list of the ids of the ingredients that have been selected). When the filters change, the filters component emits a filtersChanged
event. Other components (eg. the menu) listen for this event and when received, take the json representation of the filters and re-compute the items that match.
I have a bit of an issue with this approach:
How does one avoid the potential issue of the event payload format changing by the emitter without necessarily using tests?
Any ideas are welcome!