The Soul of Erlang and Elixir • Sasa Juric • GOTO 2019
Getting started
iex -S mix - Interactive terminal
recompile - inside interactive terminal to compile latest changes
https://github.com/h4cc/awesome-elixir
Pattern matching
Any time you see an = sign, instead of assignment think pattern matching. It’s sort of like destructuring in Javascript.
Given function deal() that returns a tuple of structure {[hand], [rest of deck]}, we can do something like {hand, rest_of_deck} = deal() and we would now have a hand variable containing the hand array, and a rest_of_deck variable containing the rest of the deck.
Similarly, given an array ["red"], we can do something like [color] = ["red"] and we will get a variable color with just the string red.
Maps
Adding a new key to an existing map
Given a map colors = %{ primary: "blue" }, we can do colors = Map.put(colors, :secondary, "red") to add a brand new key value pair.
Update an existing key in a map
Given a map colors = %{ primary: "blue" }, we can do colors = Map.put(colors, :primary, "red")
:OR:
we can do colors = %{ colors | primary: "red" } reading this as something like “pipe colors into a new map with a key primary with value "red".
Keyword Lists
Patterns and Guards - Elixir v1.14.0-dev
Idiomatic guard clause for checking not nil
Ecto
Fixing Ecto.CastError (mixed keys)
Migrations
Phoenix: Ecto migrations cheatsheet
Data Types in Ecto - “value too long for type character varying(255)”
For db columns with string type, create a migration updating to :text, leaving the type in the schema/model file as :string.
Testing
Injecting session in tests
Testing Live Views
Phoenix.LiveViewTest - Phoenix LiveView v0.17.9
Phoenix
https://github.com/thechangelog/changelog.com
Elixir & Phoenix Tutorial: Build an Authenticated App
https://github.com/aisrael/elixir-phoenix-typescript-react
Elixir Phoenix Framework - Tutorial To Build a Blog in 15 Minutes
Live View
Phoenix.LiveView - Phoenix LiveView v0.17.7
Security considerations of the LiveView model - Phoenix LiveView v0.17.7
Phoenix.LiveView - Phoenix LiveView v0.17.7
Phoenix.LiveView.Helpers - Phoenix LiveView v0.17.9
Intro to Phoenix LiveView with New Project Example - Elixir Programming Language
Live View → Live Component
Phoenix.LiveComponent - Phoenix LiveView v0.17.7
Phoenix LiveView LiveComponent
Phoenix LiveView LiveComponents
Breaking up a Phoenix LiveView module into components
https://twitter.com/mkumm/status/1511607054842093569?s=21&t=okE36k5BRxKoFnMj9e6Xyg
https://twitter.com/ryanrwinchester/status/1703193333512712552