Call the Logic from the Interface

We’ve seen that we can start a new game from within an IEx session begun with iex -S mix phx.server. That means we can call the public functions of the IslandsEngine.Game module from any Phoenix component.

At the beginning of this chapter, we talked a lot about decoupling the interface from the business logic. We made a bold claim and said that this would make our work trivially easy. Throughout the chapter, we’ve shown how we can keep the two separated but included in a common project. What we haven’t yet shown is how those two will communicate. It’s time to back up that claim.

We’re going to walk through this pretty quickly. We’ll be working with a few new files, but we won’t be spending a lot of time explaining ...

Get Functional Web Development with Elixir, OTP, and Phoenix now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.