View Source Rephex.State.Assigns (rephex v0.1.1)

Summary

Functions

Link to this function

get_state_in(socket, keys)

View Source
Link to this function

put_state_in(socket, keys, value)

View Source

Update Rephex state by put_in/3.

Example:

def put_value(socket, %{key: k, value: v} = _payload) do
  put_state_in(socket, [:items, k], v)
end
Link to this function

update_state(socket, fun)

View Source

Update Rephex state.

Example:

def add_count(socket, %{amount: amount} = _payload) do
  update_state(socket, fn state -> %{state | count: state.count + amount} end)
end
Link to this function

update_state_in(socket, keys, fun)

View Source

Update Rephex state by update_in/3.

Example:

import Rephex.State.Assigns

def mlt_count(socket, %{mlt: mlt} = _payload) do
  update_state_in(socket, [:count], &(&1 * mlt))
end