Best way to initialize Alpine JS var's initial value from wire:model in custom Livewire component

Hi,

This isn’t so much an issue as a question regarding the best way to:

  • in a custom Livewire component (e.g. a toggle (checkbox) with a custom SVG image)
  • the best way to set the component’s starting state/value from the passed wire:model attribute - without using @entangle (until some of the entangle issues discussed on GitHub have been resolved)

Currently, I’m using the following code (as an example):

<div
        x-data="{ checked: false }"
        x-init="checked = $wire.get('{{ $attributes->wire('model')->value() }}')"
>

Is there a better way?

Thanks in advance for your help/ideas!