Fix docs for Counter example#14763
Conversation
|
Thank you for the PR. I am thinking in this case it may make more sense to change the example. Because the goal here is not really to show how the GenServer works, but the supervisor, and this makes non-supervisor part of the example more verbose. Perhaps we should only have the Alternatively we implement it using an Agent, which should considerably cut down the lines of code? A third option, which perhaps is the one I prefer the most, is to rewrite this example altogether. I don't think the goal here is to show supervisor APIs, but rather to say that tools like Observer and Phoenix LiveDashboard gives us better instrospection if we supervise them. |
|
I took a stab at 3 here: #14764 - Can you please let me know what you think? |
|
Thanks José! LGTM |
The documentation in the "process anti patterns" section shows an example of a Counter which uses a GenServer in its implementation.
The bump handler replies with the current state before any bump operation has been applied to it however the iex snippet shows the new value being returned.
I chose to fix the iex snippets rather than editing the bump handler because in the docs for the Supervisor, we have a very similar example which does return the "old" value of the counter and I thought it best to keep the docs consistent.