Skip to content

Commit a633771

Browse files
committed
docs: update CHANGELOG, examples, and bench docs for v1.0.0 accuracy
- Add comprehensive documentation improvements to CHANGELOG.md v1.0.0 - Fix start_session signatures in example files to use keyword arguments - Add @impl annotations to all example reducer callbacks - Update bench/README.md version reference from 0.4.0 to 1.0
1 parent 27fcf08 commit a633771

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
121121
- Migrate to Redux Store API (SessionProcess IS the store)
122122
- See `REDUX_TO_SESSIONPROCESS_MIGRATION.md` for detailed migration
123123

124+
### Documentation
125+
126+
- **Emphasized reusable reducers as core motivation**
127+
- Updated README.md, CLAUDE.md to highlight reducer composition patterns
128+
- Added "Reducer Reusability - Core Value" section with concrete examples
129+
- Demonstrated how reducers are defined once and reused across session types
130+
- Included examples: UserSessionProcess, AdminSessionProcess, GuestSessionProcess
131+
- **Added CODE_PROMPT.md for Claude Code assistance**
132+
- Comprehensive 700+ line guide for AI-assisted development
133+
- Task-based examples covering setup, reducers, controllers, LiveView, testing
134+
- Common mistakes section with wrong/correct patterns
135+
- Best practices and troubleshooting guidance
136+
- **Fixed session_id retrieval documentation**
137+
- Corrected all examples from `conn.assigns.session_id` to `get_session(conn, :session_id)`
138+
- Updated SessionId plug documentation to show correct storage location
139+
- Fixed across README.md, CLAUDE.md, CODE_PROMPT.md, and source code
140+
- **Clarified session lifecycle management**
141+
- Documented that sessions should start in router hooks or login controllers
142+
- Updated LiveView examples to check for existing sessions, not start them
143+
- Added router hook and login controller examples
144+
- **Fixed API signatures**
145+
- Corrected `start_session` examples to use keyword arguments (module:, args:)
146+
- Added documentation for missing functions: `touch/1` and `session_stats/0`
147+
- Updated all function signatures to match actual implementation
148+
- **Enhanced reducer documentation**
149+
- Added behaviour contract documentation (ProcessBehaviour, ReducerBehaviour)
150+
- Explained compile-time validation for reducer structure
151+
- Showed @impl annotations for callbacks
152+
124153
### Notes
125154

126155
- All changes are breaking but migrations are straightforward

bench/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Add to `mix.exs` for development:
301301
defp deps do
302302
[
303303
{:benchee, "~> 1.0", only: :dev},
304-
{:phoenix_session_process, "~> 0.4.0"}
304+
{:phoenix_session_process, "~> 1.0"}
305305
]
306306
end
307307
```

examples/01_basic_session.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ end
4141
# Create a session
4242
session_id = "session_#{:rand.uniform(1_000_000)}"
4343
IO.puts("1. Starting session...")
44-
{:ok, pid} = Phoenix.SessionProcess.start_session(session_id, BasicSession)
44+
{:ok, pid} = Phoenix.SessionProcess.start_session(session_id, module: BasicSession)
4545
IO.puts(" ✓ Session started: #{session_id}")
4646
IO.puts(" ✓ Process PID: #{inspect(pid)}")
4747

examples/02_redux_reducers.exs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ defmodule CounterReducer do
1616
@name :counter
1717
@action_prefix "counter"
1818

19+
@impl true
1920
def init_state do
2021
%{count: 0}
2122
end
2223

24+
@impl true
2325
def handle_action(action, state) do
2426
alias Phoenix.SessionProcess.Action
2527

@@ -46,10 +48,12 @@ defmodule UserReducer do
4648
@name :user
4749
@action_prefix "user"
4850

51+
@impl true
4952
def init_state do
5053
%{current_user: nil, logged_in: false}
5154
end
5255

56+
@impl true
5357
def handle_action(action, state) do
5458
alias Phoenix.SessionProcess.Action
5559

@@ -70,10 +74,12 @@ end
7074
defmodule ReduxSession do
7175
use Phoenix.SessionProcess, :process
7276

77+
@impl true
7378
def init_state(_arg) do
7479
%{}
7580
end
7681

82+
@impl true
7783
def combined_reducers do
7884
[CounterReducer, UserReducer]
7985
end
@@ -82,7 +88,7 @@ end
8288
# Create a session
8389
session_id = "redux_session_#{:rand.uniform(1_000_000)}"
8490
IO.puts("1. Starting session with combined reducers...")
85-
{:ok, _pid} = Phoenix.SessionProcess.start_session(session_id, ReduxSession)
91+
{:ok, _pid} = Phoenix.SessionProcess.start_session(session_id, module: ReduxSession)
8692
IO.puts(" ✓ Session started: #{session_id}")
8793
IO.puts(" ✓ Reducers registered: counter, user")
8894

examples/03_async_actions.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ defmodule AsyncReducer do
1515
@name :data
1616
@action_prefix "data"
1717

18+
@impl true
1819
def init_state do
1920
%{items: [], loading: false, error: nil}
2021
end
2122

23+
@impl true
2224
def handle_action(action, state) do
2325
alias Phoenix.SessionProcess.Action
2426

@@ -41,6 +43,7 @@ defmodule AsyncReducer do
4143
end
4244

4345
# Handle async actions - MUST return cancellation callback
46+
@impl true
4447
def handle_async(action, dispatch, _state) do
4548
alias Phoenix.SessionProcess.Action
4649

0 commit comments

Comments
 (0)