Packages

Multi-surface application runtime for Elixir. One TEA module renders to terminal, browser (LiveView), SSH, and MCP (agents). 30+ widgets, flexbox + CSS grid, AI agent runtime, distributed swarm with CRDTs, time-travel debugging, session recording, sandboxed REPL, and agentic commerce.

Current section

Files

Jump to
raxol lib raxol core state_manager.ex
Raw

lib/raxol/core/state_manager.ex

defmodule Raxol.Core.StateManager do
@moduledoc """
Shared utilities for managing process-local state.
"""
@doc """
Executes a function with the current state, updating it if the function returns a tuple.
"""
def with_state(state_key, fun) do
state = Process.get(state_key) || %{}
case fun.(state) do
{new_state, result} ->
Process.put(state_key, new_state)
result
new_state ->
Process.put(state_key, new_state)
nil
end
end
end