Functional Web Development with Elixir, OTP, and Phoenix (Pragprog)

Hi jejuro,

I used kokolegorille’s trick: I added at the end of the /assets/app.js the line window.phoenix = require("phoenix");.
Then, in the browser’s console I called the socket like this:
var socket = new window.phoenix.Socket("/socket", {})

It worked for me and I finished the exercise from the book :slight_smile:

2 Likes

I have a question about persistence.

In the book, you create (and test) everything around Elixir structs.

When it comes time to persist these things with Ecto, do you just use Ecto.Schema on the your structs? Or do you leave the logic alone and write a parallel storage mechanism?

I think the book is outstanding btw and really extended my understanding.

1 Like

this book starts out good, but the last few chapters are extremley unsatisfying. How much more work would it have been to incorporate the js into the application code instead of typing it into the console (which i couldn’t get to work because of the require). it feels lazy.

how would you go about including the js in the application code instead of typing it into the console?

The book is directed to an “Ecto-less” project. Having that said, in 2022, which would have been the most plausible approach for introducing Ecto in such a project:
i) as part of the default Phoenix sub-project generator, or
ii) as a different project linked as a library in mix.exs of the Phoenix sub-project?