Skip to content

[LocalLiveView] Documentation - #581

Open
FranekKubis wants to merge 5 commits into
mainfrom
fk/llv-documentation
Open

[LocalLiveView] Documentation#581
FranekKubis wants to merge 5 commits into
mainfrom
fk/llv-documentation

Conversation

@FranekKubis

@FranekKubis FranekKubis commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

cd local_live_view and mix docs to generate documentation - then open doc/index.html to read

@FranekKubis
FranekKubis requested a review from mat-hek April 21, 2026 06:37
@FranekKubis
FranekKubis force-pushed the fk/llv-documentation branch 2 times, most recently from d39dc51 to 0f6a098 Compare April 21, 2026 06:51
@FranekKubis
FranekKubis force-pushed the fk/llv-documentation branch from 0f6a098 to ad3a5c2 Compare July 30, 2026 09:19
@mat-hek
mat-hek removed their request for review July 30, 2026 10:47
@FranekKubis
FranekKubis requested a review from mat-hek July 31, 2026 14:15
@FranekKubis
FranekKubis force-pushed the fk/llv-documentation branch from a13cea8 to f4b7e46 Compare July 31, 2026 14:35

@mat-hek mat-hek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to go through the modules: make sure that only the public ones are visible and that they're have up-to-date docs. Also, it seems that mix docs only generates docs for the server part. Not sure if it's in scope of this PR, but needs to be fixed before the release.


- A Phoenix project generated with `mix phx.new`
- `:local_live_view` added as a dependency
- `pnpm` or `npm` for JS package management

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC pnpm works only from popcorn repo root, so a regular user needs npm

Comment on lines +69 to +73
Visit [localhost:4000](http://localhost:4000). The installer generated a sample `HelloLocal` view — add it to any template to confirm everything works:

```heex
<.local_live_view view="HelloLocal" />
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we generate a separate page that renders HelloLocal? If so, we can just tell the user to visit that page


This should look familiar if you've used Phoenix LiveView. The differences are:

- `use LocalLiveView` instead of `use Phoenix.LiveView`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `use LocalLiveView` instead of `use Phoenix.LiveView`
This should look familiar if you've used Phoenix LiveView. The only difference is `use LocalLiveView` instead of `use Phoenix.LiveView`.

Comment on lines +51 to +63
## Building and running

After adding the module, rebuild the WASM bundle:

```bash
mix llv.build
```

Then start or reload the server:

```bash
mix phx.server
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather unnecessary, since the watcher detects changes. Besides, we describe that in the previous chapter.

Suggested change
## Building and running
After adding the module, rebuild the WASM bundle:
```bash
mix llv.build
```
Then start or reload the server:
```bash
mix phx.server
```

└── mix.exs # Compiles to WASM via popcorn.cook
```

Add your LocalLiveView modules to `local/lib/`. They will be compiled into the WASM bundle when you run `mix llv.build`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add your LocalLiveView modules to `local/lib/`. They will be compiled into the WASM bundle when you run `mix llv.build`.
Now you can add your LocalLiveView modules to `local/lib/`. When the server is running, the LLV watcher detects changes and automatically rebuilds the local code. To enforce rebuild, run `mix llv.build` and restart the server.

<.local_live_view view="ThermostatLocal" />
```

When mounting the same view multiple times, use the `id` attribute to give each instance a unique identifier.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would fit better in the LocalLiveView module. I'd move it there. In this guide, you can add short comments inside the CounterLocal code, describing what each callback does in this particular case.

Comment on lines +15 to +29
```
Browser Server
┌──────────────────────────────────────┐ ┌──────────────────┐
│ Phoenix LiveView page │ │ Phoenix app │
│ │ │ │
│ <.local_live_view view="MyLocal"> │ │ Mirror.MyLocal │
│ │ │ │ (optional) │
│ ▼ │ │ ▲ │
│ Popcorn (AtomVM WASM) │─────▶│ mirror_sync │
│ MyLocal (your Elixir code) │ │ │
│ ├── mount/3 │ └──────────────────┘
│ ├── render/1 │
│ └── handle_event/3 │
└──────────────────────────────────────┘
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to show on this picture that the server LV can render LLV, pass assigns to it and exchange events

Comment thread local-live-view/mix.exs
[
# {:popcorn, "~> 0.3.0-rc2", targets: :wasm},
{:popcorn, path: "../popcorn/elixir", targets: :wasm},
{:popcorn, "~> 0.3.0-rc2", targets: :wasm},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{:popcorn, "~> 0.3.0-rc2", targets: :wasm},
{:popcorn, "~> 0.3.2", targets: :wasm},

Comment thread local-live-view/README.md
Comment on lines +13 to +17
The source code for all examples is in the `examples/` directory of this repository:

- `local-lv-thermostat` — Basic state management and events
- `local-lv-forms` — Form handling with validation and Mirror Sync
- `local-lv-compare` — Side-by-side comparison of Phoenix LiveView vs LocalLiveView

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add kanban and burrito

Comment on lines +50 to +58
| Phoenix LiveView | LocalLiveView |
|---|---|
| `use Phoenix.LiveView` | `use LocalLiveView` |
| `mount/3` | `mount/3` |
| `render/1` with `~H` | `render/1` with `~H` |
| `handle_event/3` | `handle_event/3` |
| `assign/2`, `update/3` | `assign/2`, `update/3` |
| `phx-click` | `phx-click` |
| Runs on server | Runs in browser (WASM) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if presenting this as a table is the good approach, since both columns are almost the same, and to understand it, you need to carefully read through it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants