# `Filament.LiveComponent`

Phoenix LiveComponent adapter for embedding a Filament component inside a regular
Phoenix LiveView.

## Usage

    <.live_component
      module={Filament.LiveComponent}
      id="unique-id"
      component={MyApp.MyComponent}
      my_prop="value"
      other_prop={@something}
    />

All assigns other than `id` and `component` are passed as props to the Filament
component.

## Observable updates

Because `Filament.LiveComponent` runs inside the parent LiveView process,
observable update messages (`:filament_set_state`, `:filament_observable_updates`,
`:filament_observable_resubscribe`) arrive at the **parent** LiveView's
`handle_info/2`. The parent must forward them to the component:

    def handle_info({:filament_set_state, _fid, _slot, _val} = msg, socket) do
      Phoenix.LiveView.send_update(Filament.LiveComponent,
        id: "my-id", filament_msg: msg)
      {:noreply, socket}
    end

    def handle_info({:filament_observable_updates, _updates} = msg, socket) do
      Phoenix.LiveView.send_update(Filament.LiveComponent,
        id: "my-id", filament_msg: msg)
      {:noreply, socket}
    end

This is a Phase 1 limitation. Phase 2 will add automatic forwarding via a
host LiveView helper.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
