You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,14 @@ Lissome is a library to integrate the [Gleam](https://gleam.run/) frontend frame
9
9
10
10
First, make sure you have the Gleam compiler installed. Instructions can be found [here](https://gleam.run/getting-started/installing/)
11
11
12
-
1. Add `lissome` to your `mix.exs` file:
12
+
1. Add `lissome`and `lustre`to your `mix.exs` file:
13
13
14
14
```elixir
15
15
defdepsdo
16
16
[
17
17
...,
18
-
{:lissome, "~> 0.3.0"},
18
+
{:lissome, "~> 0.3.1"},
19
+
{:lustre, "~> 4.6.3", app:false, manager::rebar3}
19
20
]
20
21
end
21
22
```
@@ -184,13 +185,14 @@ Check out the project in the `example` directory for a complete code example.
184
185
185
186
## SSR
186
187
187
-
Thanks to the ability of Gleam to compile to both Erlang and JavaScript, we can do server-side rendering of Lustre without having to install Node.js. We only need to make sure we compile the Gleam project to Erlang too. For that, add the `:gleam` compiler to your list fo compilers:
188
+
Thanks to the ability of Gleam to compile to both Erlang and JavaScript, we can do server-side rendering of Lustre without having to install Node.js. We only need to make sure we compile the Gleam project to Erlang too. For that, install Lustre in your Elixir project and add the `:gleam` compiler to your list fo compilers:
188
189
189
190
```elixir
190
191
# mix.exs
191
192
defprojectdo
192
193
[
193
-
compilers:Mix.compilers() ++ [:gleam]
194
+
compilers:Mix.compilers() ++ [:gleam],
195
+
deps:deps()
194
196
]
195
197
end
196
198
```
@@ -229,6 +231,8 @@ The type your flags has must be public too. Lissome will use this type to constr
229
231
/>
230
232
```
231
233
234
+
Remember to add to your `mix.exs` file any other dependencies your Gleam project needs apart from Lustre and the Gleam standard library. You can add Gleam dependencies to Mix like any other dependency, but with the `app: false` and `manager: :rebar3` options.
235
+
232
236
## Communicating with Phoenix LiveView
233
237
234
238
`Lissome` includes helpers for communicating with a LiveView running in the server from Gleam code, using [Lustre's effects for managed side effects](https://hexdocs.pm/lustre/guide/03-side-effects.html). To enable this bidirectional communication, you need to construct your app with `lissome.application`. This is a wrapper around `lustre.application` that allows your `init` and `update` function to receive the LiveView hook instance as an argument. This instance could be used to communicate with the server by passing it to the functions in the `lissome/live_view` module.
0 commit comments