Programming Phoenix LiveView Book Club!

Chapter 3

Fantastic chapter! It is basically a chapter about structuring Elixir software, and some very valuable concepts are introduced.

The most important takeaway for me from this chapter was the concept of the Context and the Core of a resource.

The Context

The context is the API to the resource, every interaction with the resource goes through the context module (in this case the Products module). Every unpure function goes here (functions that can perform I/O, might fail, etc.). The with function can often be put to good use in the context.

The Core

All pure functions go here. The schema, query builders, etc. Core functions are often suitable for piping.

Best quotes of the chapter:

  • “The Context API is with-land”
  • “The Core is pipe-land”

Now, in the code used so far, the context and the core is very easy to separate since it’s just the Products module and the Product module. I hope the book will keep referring to these concepts as the application grows.

Next up is the frontend in Chapter 4 :smiley:

7 Likes