...

/

Building Scenic Projects with Layers

Building Scenic Projects with Layers

Let’s learn how Scenic works in using OTP to make graphs on the user interface.

For this feature, let’s go from the outside in, addressing the outer API layer first. That way, we can think about the shape of our external APIs.

Pulling a persistence function from the environment

In /lib/mastery.ex, we need to pull a persistence function from the environment to dictate the persistence mechanism, like this:

Press + to interact
@persistence_fn Application.get_env(:mastery, :persistence_fn)

Easy enough. We pass in another argument, a function to optionally persist each new response. The responsibility of the function from Mastery’s perspective is to return a response. We can use it any way we want. We might decide to save a response to a database or file or do nothing at all. ...