#Looking for someone to review a small project

13 messages · Page 1 of 1 (latest)

stiff forum
#

I have a small Elixir/React project and I would appreciate a review of it.

main hamlet
#

post it on github

stiff forum
sage cairn
#
  1. Do not call GenServer functions outside of module that implement behaviour
  2. You have race condition in your application supervisor. BearCounter should be above Endpoint
  3. I do not see reason for BearCounterSupervisor
glass raven
#

Ok, I'm coming from the Erlang side, but just a comment on bear_counter.ex ; I would collect my API functions (e.g those using GenServer.call) at the top, then collect the GenServer callbacks, and at the bottom of the file any Helper code. In the Erlang emacs-mode there used to exist a gen-server skeleton, not sure if something similar exist in the Elixir world.

sage cairn
#

In Elixir most of that skeleton is not needed as Elixir's wrapper provide default implementation for all functions except init/1

glass raven
#

also in your handle_call's you return the 'state', is that intentional? usually you would return ':ok' or '{:ok, a_result_value}' or '{:error, reason}'

glass raven
sage cairn
glass raven
#

yes, well the example is a bit too simple I guess since the state just is the counter itself

stiff forum
#

@sage cairn 1. Ah that was an oversight
2. How is there a race condition?
3. Makes sense.. I may just leave it anyways, though.

#

@glass raven Don't I already have the GenServer callbacks at the bottom and public functions at the top?
Regarding returning {:ok, result} I don't really see the need right now!

minor abyss
#

I think the race condition is happening because of the Endpoint therefore the BearCounterController is waking up first. At that time the BearCounter is not ready for use. That is why you should write the BearCounterSupervisor above the Endpoint.