March 2025
Intermediate to advanced
202 pages
4h 45m
English
So far, the schema for the structures used by applications has been done without much fanfare. In the Lunar Frontiers application, the schemas are part of the structure definitions, such as this building spawned event:
| | defmodule LunarFrontiers.App.Events.BuildingSpawned.V2 do |
| | @derive Jason.Encoder |
| | defstruct [:site_id, |
| | :game_id, |
| | :site_type, |
| | :location, |
| | :player_id, |
| | :tick, |
| | :completion_ticks] |
| | end |
Of course, this isn’t truly a schema as much as it is a list of untyped fields. Elixir’s relationship with strong typing is a complex one, but type specifications can be added to structures like this to give developers a better understanding of what’s actually in an event. For example, ...
Read now
Unlock full access