One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8
To use the new phx.new project generator, you can install the archive with the following command:
$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:
tic -x resources/xterm-256color-italic.terminfo
tic -x resources/tmux-256color-italic.terminfodefmodule DemoServer do
use GenServer
- @vsn "1"
+ @vsn "2"
## Client API
def start_link employee do
GenServer.start_link __MODULE__, employee, []
end| defmodule DemoServer do | |
| use GenServer | |
| ## Server API | |
| def init(employee) do # initiating the state with the value 1 passed | |
| {:ok, employee} | |
| end | |
| # add the value to the state and returns :ok |
| defmodule Bank.Supervisor do | |
| use Supervisor | |
| def start_link(initial_balance) do | |
| bank_supervisor = {:ok, sup} = Supervisor.start_link(__MODULE__, [initial_balance]) | |
| start_children(sup, initial_balance) | |
| bank_supervisor | |
| end | |
| def start_children(sup, initial_balance) do | |
| {:ok, cache_pid} = | |
| Supervisor.start_child(sup, worker(Bank.Cache, [initial_balance])) |
| defmodule Bank.Cache do | |
| use GenServer | |
| def start_link initial_balance do | |
| GenServer.start_link(__MODULE__, initial_balance) | |
| end | |
| def init(initial_balance) do | |
| {:ok, initial_balance} | |
| end | |
| def get_balance(pid) do | |
| GenServer.call pid, :get |
| defmodule Bank do | |
| use GenServer | |
| alias Bank.Cache | |
| @moduledoc """ | |
| Documentation for Bank. | |
| """ | |
| # client API | |
| def start_link(cache_pid) do | |
| GenServer.start_link(Bank, cache_pid, name: Bank) | |
| end |
| # stack.ex | |
| defmodule Stack do | |
| use GenServer | |
| # server callbacks | |
| def init(args), do: {:ok, args} | |
| #used to handle synchronous requests | |
| def handle_call(:get, _from, state) do |
| # Elixir V1.6 | |
| defmodule Array do | |
| @moduledoc """ | |
| A collective data module with some helpful functions | |
| """ | |
| @doc """ | |
| Flattens the given list of nested lists. By default it gives out the unique list of items by removing the duplicates | |
| inside. |